This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

signuppage.php

By: numinous on Nov 13th, 2012  |  syntax: PHP  |  size: 7.66 KB  |  views: 53  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. /*
  3.  
  4.     This file is part of Join My Multisite, a plugin for WordPress.
  5.  
  6.     Join My Multisite is free software: you can redistribute it and/or modify
  7.     it under the terms of the GNU General Public License as published by
  8.     the Free Software Foundation, either version 2 of the License, or
  9.     (at your option) any later version.
  10.  
  11.     Sitewide Comment Control is distributed in the hope that it will be useful,
  12.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.     GNU General Public License for more details.
  15.  
  16.     You should have received a copy of the GNU General Public License
  17.     along with WordPress.  If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. if (!defined('ABSPATH')) {
  20.     die();
  21. }
  22.  
  23. //$jmm_options = get_option( 'helfjmm_options' );
  24. //    if ( !is_null($jmm_options['perpage']) && $jmm_options['perpage'] != "XXXXXX"  )
  25. //        {$goto = get_permalink($jmm_options['perpage']); echo get_permalink($jmm_options['perpage']); echo $goto; }
  26. //    else
  27. //        {$goto = '/wp-signup.php'; echo 'hi2'; }
  28. ?>
  29.         <style type="text/css">
  30.                 .mu_register { width: 90%; margin:0 auto; }
  31.                 .mu_register form { margin-top: 2em; }
  32.                 .mu_register .error { font-weight:700; padding:10px; color:#333333; background:#FFEBE8; border:1px solid #CC0000; }
  33.                 .mu_register input[type="submit"],
  34.                         .mu_register #blog_title,
  35.                         .mu_register #user_email,
  36.                         .mu_register #blogname,
  37.                         .mu_register #user_name { width:100%; font-size: 24px; margin:5px 0; }
  38.                 .mu_register .prefix_address,
  39.                         .mu_register .suffix_address {font-size: 18px;display:inline; }
  40.                 .mu_register label { font-weight:700; font-size:15px; display:block; margin:10px 0; }
  41.                 .mu_register label.checkbox { display:inline; }
  42.                 .mu_register .mu_alert { font-weight:700; padding:10px; color:#333333; background:#ffffe0; border:1px solid #e6db55; }
  43.         </style>
  44.  
  45. <div id="content" class="widecolumn">
  46. <div class="mu_register">
  47. <?php
  48.  
  49. function show_user_form($user_name = '', $user_email = '', $errors = '') {
  50.         // User name
  51.         echo '<label for="user_name">' . __('Username:', 'helfjmm') . '</label>';
  52.         if ( $errmsg = $errors->get_error_message('user_name') ) {
  53.                 echo '<p class="error">'.$errmsg.'</p>';
  54.         }
  55.         echo '<input name="user_name" type="text" id="user_name" value="'. esc_attr($user_name) .'" maxlength="60" /><br />';
  56.         _e( '(Must be at least 4 characters, letters and numbers only.)', 'helfjmm' );
  57.         ?>
  58.  
  59.         <label for="user_email"><?php _e( 'Email&nbsp;Address:', 'helfjmm' ) ?></label>
  60.         <?php if ( $errmsg = $errors->get_error_message('user_email') ) { ?>
  61.                 <p class="error"><?php echo $errmsg ?></p>
  62.         <?php } ?>
  63.         <input name="user_email" type="text" id="user_email" value="<?php  echo esc_attr($user_email) ?>" maxlength="200" /><br /><?php _e('We send your registration email to this address. (Double-check your email address before continuing.)', 'helfjmm') ?>
  64.         <?php
  65.         if ( $errmsg = $errors->get_error_message('generic') ) {
  66.                 echo '<p class="error">' . $errmsg . '</p>';
  67.         }
  68.         do_action( 'signup_extra_fields', $errors );
  69. }
  70.  
  71. function validate_user_form() {
  72.         return wpmu_validate_user_signup($_POST['user_name'], $_POST['user_email']);
  73. }
  74.  
  75. function signup_user($user_name = '', $user_email = '', $errors = '') {
  76.         global $current_site, $active_signup;
  77.  
  78.  
  79. $jmm_options = get_option( 'helfjmm_options' );
  80.     if ( !is_null($jmm_options['perpage']) && $jmm_options['perpage'] != "XXXXXX"  )
  81.         {$goto = get_permalink($jmm_options['perpage']); }
  82.     else
  83.         {$goto = '/wp-signup.php';}
  84.  
  85.  
  86.         if ( !is_wp_error($errors) )
  87.                 $errors = new WP_Error();
  88.  
  89.         $signup_for = isset( $_POST[ 'signup_for' ] ) ? esc_html( $_POST[ 'signup_for' ] ) : 'blog';
  90.  
  91.         // allow definition of default variables
  92.         $filtered_results = apply_filters('signup_user_init', array('user_name' => $user_name, 'user_email' => $user_email, 'errors' => $errors ));
  93.         $user_name = $filtered_results['user_name'];
  94.         $user_email = $filtered_results['user_email'];
  95.         $errors = $filtered_results['errors'];
  96.        
  97.         $blog_details = get_blog_details($current_site->blog_id);
  98.  
  99.         ?>
  100.  
  101.         <h2><?php printf( __( 'Get a user account on %s in seconds', 'helfjmm' ), $blog_details->blogname ) ?></h2>
  102.         <form id="setupform" method="post" action="<?php echo $goto; ?>">
  103.                 <input type="hidden" name="stage" value="validate-user-signup" />
  104.                 <?php do_action( 'signup_hidden_fields' ); ?>
  105.                 <?php show_user_form($user_name, $user_email, $errors); ?>
  106.  
  107.                 <p>
  108.                         <input id="signupblog" type="hidden" name="signup_for" value="user" />
  109.                 </p>
  110.  
  111.                 <p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e('Sign Up', 'helfjmm') ?>" /></p>
  112.         </form>
  113.         <?php
  114. }
  115.  
  116. function validate_user_signup() {
  117.         $result = validate_user_form();
  118.         extract($result);
  119.  
  120.         if ( $errors->get_error_code() ) {
  121.                 signup_user($user_name, $user_email, $errors);
  122.                 return false;
  123.         }
  124.  
  125.         if ( 'blog' == $_POST['signup_for'] ) {
  126.                 signup_blog($user_name, $user_email);
  127.                 return false;
  128.         }
  129.  
  130.         wpmu_signup_user($user_name, $user_email, apply_filters( 'add_signup_meta', array() ) );
  131.  
  132.         confirm_user_signup($user_name, $user_email);
  133.         return true;
  134. }
  135.  
  136. function confirm_user_signup($user_name, $user_email) {
  137.         ?>
  138.         <h2><?php printf( __( '%s is your new username' ), $user_name) ?></h2>
  139.         <p><?php _e( 'But, before you can start using your new username, <strong>you must activate it</strong>.', 'helfjmm' ) ?></p>
  140.         <p><?php printf( __( 'Check your inbox at <strong>%s</strong> and click the link given.', 'helfjmm' ), $user_email ); ?></p>
  141.         <p><?php _e( 'If you do not activate your username within two days, you will have to sign up again.', 'helfjmm' ); ?></p>
  142.         <?php
  143.         do_action( 'signup_finished' );
  144. }
  145.  
  146. // Main
  147. $active_signup = get_site_option( 'registration' );
  148. if ( !$active_signup )
  149.         $active_signup = 'all';
  150.  
  151. $active_signup = apply_filters( 'wpmu_active_signup', $active_signup ); // return "all", "none", "blog" or "user"
  152.  
  153. // Make the signup type translatable.
  154. $i18n_signup['all'] = _x('all', 'Multisite active signup type');
  155. $i18n_signup['none'] = _x('none', 'Multisite active signup type');
  156. $i18n_signup['blog'] = _x('blog', 'Multisite active signup type');
  157. $i18n_signup['user'] = _x('user', 'Multisite active signup type');
  158.  
  159. if ( is_super_admin() )
  160.         echo '<div class="mu_alert">' . sprintf( __( 'Greetings Site Administrator! You are currently allowing &#8220;%s&#8221; registrations. To change or disable registration go to your <a href="%s">Options page</a>.', 'helfjmm' ), $i18n_signup[$active_signup], esc_url( network_admin_url( 'settings.php' ) ) ) . '</div>';
  161.  
  162. $newblogname = isset($_GET['new']) ? strtolower(preg_replace('/^-|-$|[^-a-zA-Z0-9]/', '', $_GET['new'])) : null;
  163.  
  164. $current_user = wp_get_current_user();
  165. if ( $active_signup == 'none' ) {
  166.         _e( 'Registration has been disabled.' );
  167. } else {
  168.         $stage = isset( $_POST['stage'] ) ?  $_POST['stage'] : 'default';
  169.         switch ( $stage ) {
  170.                 case 'validate-user-signup' :
  171.                         if ( $active_signup == 'all' || $_POST[ 'signup_for' ] == 'blog' && $active_signup == 'blog' || $_POST[ 'signup_for' ] == 'user' && $active_signup == 'user' )
  172.                                 validate_user_signup();
  173.                         else
  174.                                 _e( 'User registration has been disabled.', 'helfjmm' );
  175.                 break;
  176.                 case 'default':
  177.                 default :
  178.                         $user_email = isset( $_POST[ 'user_email' ] ) ? $_POST[ 'user_email' ] : '';
  179.                         do_action( 'preprocess_signup_form' ); // populate the form from invites, elsewhere?
  180.                         if ( is_user_logged_in() == false && ( $active_signup == 'all' || $active_signup == 'user' ) )
  181.                                 signup_user( $user_email );
  182.                         else
  183.                                 _e( 'You are logged in already. No need to register again!', 'helfjmm' );
  184.                         break;
  185.         }
  186. }
  187. ?>
  188. </div>
  189. </div>
  190. <?php do_action( 'after_signup_form' ); ?>
clone this paste RAW Paste Data