Exemple #1
0
/**
 * Validate new site signup
 *
 * @since MU
 *
 * @return bool True if the site signup was validated, false if error
 */
function validate_blog_signup() {
	// Re-validate user info.
	$user_result = wpmu_validate_user_signup( $_POST['user_name'], $_POST['user_email'] );
	$user_name = $user_result['user_name'];
	$user_email = $user_result['user_email'];
	$user_errors = $user_result['errors'];

	if ( $user_errors->get_error_code() ) {
		signup_user( $user_name, $user_email, $user_errors );
		return false;
	}

	$result = wpmu_validate_blog_signup( $_POST['blogname'], $_POST['blog_title'] );
	$domain = $result['domain'];
	$path = $result['path'];
	$blogname = $result['blogname'];
	$blog_title = $result['blog_title'];
	$errors = $result['errors'];

	if ( $errors->get_error_code() ) {
		signup_blog($user_name, $user_email, $blogname, $blog_title, $errors);
		return false;
	}

	$public = (int) $_POST['blog_public'];
	$signup_meta = array ('lang_id' => 1, 'public' => $public);

	/** This filter is documented in wp-signup.php */
	$meta = apply_filters( 'add_signup_meta', $signup_meta );

	wpmu_signup_blog($domain, $path, $blog_title, $user_name, $user_email, $meta);
	confirm_blog_signup($domain, $path, $blog_title, $user_name, $user_email, $meta);
	return true;
}
/**
 * Validate new site signup
 *
 * @since MU
 *
 * @uses wpmu_validate_user_signup() to retrieve an array of the new user data and errors
 * @uses wpmu_validate_blog_signup() to retrieve an array of the new site data and errors
 * @uses apply_filters() to make signup $meta filterable
 * @uses signup_user() to signup a new user
 * @uses signup_blog() to signup a the new user to a new site
 * @return bool True if the site signup was validated, false if error
 */
function validate_blog_signup()
{
    // Re-validate user info.
    $result = wpmu_validate_user_signup($_POST['user_name'], $_POST['user_email']);
    extract($result);
    if ($errors->get_error_code()) {
        signup_user($user_name, $user_email, $errors);
        return false;
    }
    $result = wpmu_validate_blog_signup($_POST['blogname'], $_POST['blog_title']);
    extract($result);
    if ($errors->get_error_code()) {
        signup_blog($user_name, $user_email, $blogname, $blog_title, $errors);
        return false;
    }
    $public = (int) $_POST['blog_public'];
    $meta = array('lang_id' => 1, 'public' => $public);
    //duplicate_hook
    $meta = apply_filters('add_signup_meta', $meta);
    wpmu_signup_blog($domain, $path, $blog_title, $user_name, $user_email, $meta);
    confirm_blog_signup($domain, $path, $blog_title, $user_name, $user_email, $meta);
    return true;
}
Exemple #3
0
 public static function gf_create_user($entry, $form, $fulfilled = false)
 {
     self::log_debug("form #{$form['id']} - starting gf_create_user().");
     global $wpdb;
     // if the entry is marked as spam
     if (rgar($entry, 'status') == 'spam') {
         self::log_debug('gf_create_user(): aborting. Entry is marked as spam.');
         return;
     }
     $config = self::get_active_config($form, $entry);
     $is_update_feed = rgars($config, 'meta/feed_type') == 'update';
     // if there is no registration feed or the feed is not active, abandon ship
     if (!$config || !$config['is_active']) {
         self::log_debug('gf_create_user(): aborting. No feed or feed is inactive.');
         return;
     }
     $user_data = self::get_user_data($entry, $form, $config, $is_update_feed);
     if (!$user_data) {
         self::log_debug('gf_create_user(): aborting. user_login or user_email are empty.');
         return;
     }
     // if PayPal Add-on was used for this entry, integrate
     $paypal_config = self::get_paypal_config($form["id"], $entry);
     $delay_paypal_registration = 0;
     $password = '';
     if ($paypal_config) {
         $order_total = GFCommon::get_order_total($form, $entry);
         // delay the registration IF:
         // - the delay registration option is checked
         // - the order total does NOT equal zero (no delay since there will never be a payment)
         // - the payment has not already been fulfilled
         $delay_paypal_registration = $paypal_config['meta']['delay_registration'];
         if ($paypal_config && $delay_paypal_registration && $order_total != 0 && !$fulfilled) {
             self::log_debug('gf_create_user(): aborting. Registration delayed by PayPal feed configuration.');
             //Saving encrypted password in meta
             gform_update_meta($entry['id'], 'userregistration_password', self::encrypt($user_data['password']));
             return;
         } else {
             if ($paypal_config && $delay_paypal_registration && $order_total != 0 && $fulfilled) {
                 //reading encrypted password from meta and removing meta
                 $password = gform_get_meta($entry['id'], 'userregistration_password');
                 if ($password) {
                     $password = self::decrypt($password);
                     gform_delete_meta($entry['id'], 'userregistration_password');
                 }
             }
         }
     }
     // provide filter to allow add-ons to disable registration if needed
     $disable_registration = apply_filters('gform_disable_registration', false, $form, $entry, $fulfilled);
     if ($disable_registration) {
         self::log_debug('gf_create_user(): aborting. gform_disable_registration hook was used.');
         return;
     }
     $user_activation = rgars($config, 'meta/user_activation');
     // if about to create user, check if activation required... only use activation if payment is not fulfilled by payment
     //if manual activation and paypal set to delay registration and paypal fulfilled, need to put in signups table
     if (!$is_update_feed && $user_activation && !$fulfilled || !$is_update_feed && $user_activation && $fulfilled && $delay_paypal_registration) {
         require_once self::get_base_path() . '/includes/signups.php';
         GFUserSignups::prep_signups_functionality();
         $meta = array('lead_id' => $entry['id'], 'user_login' => $user_data['user_login'], 'email' => $user_data['user_email'], 'password' => self::encrypt($user_data['password']));
         $meta = apply_filters('gform_user_registration_signup_meta', $meta, $form, $entry, $config);
         $meta = apply_filters("gform_user_registration_signup_meta_{$form['id']}", $meta, $form, $entry, $config);
         $ms_options = rgars($config, 'meta/multisite_options');
         // save current user details in wp_signups for future activation
         if (is_multisite() && rgar($ms_options, 'create_site') && ($site_data = self::get_site_data($entry, $form, $config))) {
             wpmu_signup_blog($site_data['domain'], $site_data['path'], $site_data['title'], $user_data['user_login'], $user_data['user_email'], $meta);
         } else {
             // wpmu_signup_user() does the following sanitization of the user_login before saving it to the database,
             // we can run this same code here to allow successful retrievel of the activation_key without actually
             // changing the user name when it is activated. 'd smith' => 'dsmith', but when activated, username is 'd smith'.
             $user_data['user_login'] = preg_replace('/\\s+/', '', sanitize_user($user_data['user_login'], true));
             self::log_debug("Calling wpmu_signup_user (sends email with activation link) with login: "******" email: " . $user_data['user_email'] . " meta: " . print_r($meta, true));
             wpmu_signup_user($user_data['user_login'], $user_data['user_email'], $meta);
             self::log_debug("Done with wpmu_signup_user");
         }
         $activation_key = $wpdb->get_var($wpdb->prepare("SELECT activation_key FROM {$wpdb->signups} WHERE user_login = %s ORDER BY registered DESC LIMIT 1", $user_data['user_login']));
         // used for filtering on activation listing UI
         GFUserSignups::add_signup_meta($entry['id'], $activation_key);
         // abort current sign up, user must activate
         return;
     }
     if ($is_update_feed) {
         self::update_user($entry, $form, $config);
     } else {
         //only run create_user when manual/email activation NOT set
         if (!$user_activation) {
             self::log_debug("in gf_create_user - calling create_user");
             self::create_user($entry, $form, $config, $password);
         }
     }
 }
function bp_core_signup_blog($blog_domain, $blog_path, $blog_title, $user_name, $user_email, $usermeta)
{
    if (!is_multisite() || !function_exists('wpmu_signup_blog')) {
        return false;
    }
    return apply_filters('bp_core_signup_blog', wpmu_signup_blog($blog_domain, $blog_path, $blog_title, $user_name, $user_email, $usermeta));
}
/**
 * Create a blog and user based on data supplied at user registration.
 *
 * @since 1.2.2
 *
 * @param string $blog_domain Domain requested by user.
 * @param string $blog_path   Path requested by user.
 * @param string $blog_title  Title as entered by user.
 * @param string $user_name   user_login of requesting user.
 * @param string $user_email  Email address of requesting user.
 * @param string $usermeta    Miscellaneous metadata for the user.
 * @return bool
 */
function bp_core_signup_blog($blog_domain, $blog_path, $blog_title, $user_name, $user_email, $usermeta)
{
    if (!is_multisite() || !function_exists('wpmu_signup_blog')) {
        return false;
    }
    /**
     * Filters the result of wpmu_signup_blog().
     *
     * This filter provides no value and is retained for
     * backwards compatibility.
     *
     * @since 1.2.2
     *
     * @param void $value
     */
    return apply_filters('bp_core_signup_blog', wpmu_signup_blog($blog_domain, $blog_path, $blog_title, $user_name, $user_email, $usermeta));
}
        /**
         * Displays the registration page
         *
         * @since 6.1
         * @access public
         *
         * @param object $template Theme_My_Login_Template object
         */
        public function tml_display_register(&$template)
        {
            global $wpdb, $blogname, $blog_title, $domain, $path, $active_signup;
            $theme_my_login = Theme_My_Login::get_object();
            do_action('before_signup_form');
            echo '<div class="login mu_register" id="theme-my-login' . esc_attr($template->get_option('instance')) . '">';
            $active_signup = get_site_option('registration');
            if (!$active_signup) {
                $active_signup = 'all';
            }
            $active_signup = apply_filters('wpmu_active_signup', $active_signup);
            // return "all", "none", "blog" or "user"
            // Make the signup type translatable.
            $i18n_signup['all'] = _x('all', 'Multisite active signup type');
            $i18n_signup['none'] = _x('none', 'Multisite active signup type');
            $i18n_signup['blog'] = _x('blog', 'Multisite active signup type');
            $i18n_signup['user'] = _x('user', 'Multisite active signup type');
            if (is_super_admin()) {
                echo '<p class="message">' . 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>.', 'theme-my-login'), $i18n_signup[$active_signup], esc_url(network_admin_url('ms-options.php'))) . '</p>';
            }
            $newblogname = isset($_GET['new']) ? strtolower(preg_replace('/^-|-$|[^-a-zA-Z0-9]/', '', $_GET['new'])) : null;
            $current_user = wp_get_current_user();
            if ($active_signup == "none") {
                _e('Registration has been disabled.', 'theme-my-login');
            } elseif ($active_signup == 'blog' && !is_user_logged_in()) {
                printf(__('You must first <a href="%s">log in</a>, and then you can create a new site.', 'theme-my-login'), wp_login_url(Theme_My_Login_Common::get_current_url()));
            } else {
                $stage = isset($_POST['stage']) ? $_POST['stage'] : 'default';
                switch ($stage) {
                    case 'validate-user-signup':
                        if ($active_signup == 'all' || $_POST['signup_for'] == 'blog' && $active_signup == 'blog' || $_POST['signup_for'] == 'user' && $active_signup == 'user') {
                            $result = wpmu_validate_user_signup($_POST['user_name'], $_POST['user_email']);
                            extract($result);
                            $theme_my_login->errors = $errors;
                            if ($errors->get_error_code()) {
                                $this->signup_user($user_name, $user_email);
                                break;
                            }
                            if ('blog' == $_POST['signup_for']) {
                                $this->signup_blog($user_name, $user_email);
                                break;
                            }
                            wpmu_signup_user($user_name, $user_email, apply_filters('add_signup_meta', array()));
                            ?>
						<h2><?php 
                            printf(__('%s is your new username', 'theme-my-login'), $user_name);
                            ?>
</h2>
						<p><?php 
                            _e('But, before you can start using your new username, <strong>you must activate it</strong>.', 'theme-my-login');
                            ?>
</p>
						<p><?php 
                            printf(__('Check your inbox at <strong>%1$s</strong> and click the link given.', 'theme-my-login'), $user_email);
                            ?>
</p>
						<p><?php 
                            _e('If you do not activate your username within two days, you will have to sign up again.', 'theme-my-login');
                            ?>
</p>
						<?php 
                            do_action('signup_finished');
                        } else {
                            _e('User registration has been disabled.', 'theme-my-login');
                        }
                        break;
                    case 'validate-blog-signup':
                        if ($active_signup == 'all' || $active_signup == 'blog') {
                            // Re-validate user info.
                            $result = wpmu_validate_user_signup($_POST['user_name'], $_POST['user_email']);
                            extract($result);
                            $theme_my_login->errors = $errors;
                            if ($errors->get_error_code()) {
                                $this->signup_user($user_name, $user_email);
                                break;
                            }
                            $result = wpmu_validate_blog_signup($_POST['blogname'], $_POST['blog_title']);
                            extract($result);
                            $theme_my_login->errors = $errors;
                            if ($errors->get_error_code()) {
                                $this->signup_blog($user_name, $user_email, $blogname, $blog_title);
                                break;
                            }
                            $public = (int) $_POST['blog_public'];
                            $meta = array('lang_id' => 1, 'public' => $public);
                            $meta = apply_filters('add_signup_meta', $meta);
                            wpmu_signup_blog($domain, $path, $blog_title, $user_name, $user_email, $meta);
                            ?>
						<h2><?php 
                            printf(__('Congratulations! Your new site, %s, is almost ready.', 'theme-my-login'), "<a href='http://{$domain}{$path}'>{$blog_title}</a>");
                            ?>
</h2>

						<p><?php 
                            _e('But, before you can start using your site, <strong>you must activate it</strong>.', 'theme-my-login');
                            ?>
</p>
						<p><?php 
                            printf(__('Check your inbox at <strong>%s</strong> and click the link given.', 'theme-my-login'), $user_email);
                            ?>
</p>
						<p><?php 
                            _e('If you do not activate your site within two days, you will have to sign up again.', 'theme-my-login');
                            ?>
</p>
						<h2><?php 
                            _e('Still waiting for your email?', 'theme-my-login');
                            ?>
</h2>
						<p>
							<?php 
                            _e('If you haven&#8217;t received your email yet, there are a number of things you can do:', 'theme-my-login');
                            ?>
							<ul id="noemail-tips">
								<li><p><strong><?php 
                            _e('Wait a little longer. Sometimes delivery of email can be delayed by processes outside of our control.', 'theme-my-login');
                            ?>
</strong></p></li>
								<li><p><?php 
                            _e('Check the junk or spam folder of your email client. Sometime emails wind up there by mistake.', 'theme-my-login');
                            ?>
</p></li>
								<li><?php 
                            printf(__('Have you entered your email correctly?  You have entered %s, if it&#8217;s incorrect, you will not receive your email.', 'theme-my-login'), $user_email);
                            ?>
</li>
							</ul>
						</p>
						<?php 
                            do_action('signup_finished');
                        } else {
                            _e('Site registration has been disabled.', 'theme-my-login');
                        }
                        break;
                    case 'gimmeanotherblog':
                        $current_user = wp_get_current_user();
                        if (!is_user_logged_in()) {
                            die;
                        }
                        $result = wpmu_validate_blog_signup($_POST['blogname'], $_POST['blog_title'], $current_user);
                        extract($result);
                        $theme_my_login->errors = $errors;
                        if ($errors->get_error_code()) {
                            $this->signup_another_blog($blogname, $blog_title);
                            break;
                        }
                        $public = (int) $_POST['blog_public'];
                        $meta = apply_filters('signup_create_blog_meta', array('lang_id' => 1, 'public' => $public));
                        // deprecated
                        $meta = apply_filters('add_signup_meta', $meta);
                        wpmu_create_blog($domain, $path, $blog_title, $current_user->ID, $meta, $wpdb->siteid);
                        ?>
					<h2><?php 
                        printf(__('The site %s is yours.', 'theme-my-login'), "<a href='http://{$domain}{$path}'>{$blog_title}</a>");
                        ?>
</h2>
					<p>
						<?php 
                        printf(__('<a href="http://%1$s">http://%2$s</a> is your new site.  <a href="%3$s">Log in</a> as &#8220;%4$s&#8221; using your existing password.', 'theme-my-login'), $domain . $path, $domain . $path, "http://" . $domain . $path . "wp-login.php", $current_user->user_login);
                        ?>
					</p>
					<?php 
                        do_action('signup_finished');
                        break;
                    case 'default':
                    default:
                        $user_email = isset($_POST['user_email']) ? $_POST['user_email'] : '';
                        do_action('preprocess_signup_form');
                        // populate the form from invites, elsewhere?
                        if (is_user_logged_in() && ($active_signup == 'all' || $active_signup == 'blog')) {
                            $this->signup_another_blog($newblogname);
                        } elseif (is_user_logged_in() == false && ($active_signup == 'all' || $active_signup == 'user')) {
                            $this->signup_user($newblogname, $user_email);
                        } elseif (is_user_logged_in() == false && $active_signup == 'blog') {
                            _e('Sorry, new registrations are not allowed at this time.', 'theme-my-login');
                        } else {
                            _e('You are logged in already. No need to register again!', 'theme-my-login');
                        }
                        if ($newblogname) {
                            $newblog = get_blogaddress_by_name($newblogname);
                            if ($active_signup == 'blog' || $active_signup == 'all') {
                                printf(__('<p><em>The site you were looking for, <strong>%s</strong> does not exist, but you can create it now!</em></p>', 'theme-my-login'), $newblog);
                            } else {
                                printf(__('<p><em>The site you were looking for, <strong>%s</strong>, does not exist.</em></p>', 'theme-my-login'), $newblog);
                            }
                        }
                        break;
                }
            }
            echo '</div>';
            do_action('after_signup_form');
        }
        public function rpr_preprocess_signup_form()
        {
            global $active_signup, $stage;
            switch ($stage) {
                case 'user-signup':
                    if ($active_signup == 'all' || $_POST['signup_for'] == 'blog' && $active_signup == 'blog' || $_POST['signup_for'] == 'user' && $active_signup == 'user') {
                        /* begin validate_user_signup stage */
                        // validate signup form, do wpmu_validate_user_signup action
                        $result = wpmu_validate_user_signup(isset($_POST['user_name']) ? (string) $_POST['user_name'] : "", isset($_POST['user_email']) ? (string) $_POST['user_email'] : "");
                        extract($result);
                        if ($errors->get_error_code()) {
                            echo "signup_user";
                            signup_user($user_name, $user_email, $errors);
                            do_action('after_signup_form');
                            get_footer();
                            exit;
                        }
                        if ('blog' === $_POST['signup_for']) {
                            echo "signup_blog";
                            signup_blog($user_name, $user_email);
                            do_action('after_signup_form');
                            get_footer();
                            exit;
                        }
                        // collect meta, commit user to database, send email
                        wpmu_signup_user($user_name, $user_email, apply_filters('add_signup_meta', array()));
                        // previously, displayed confirm_user_signup message before signup_finished action
                        do_action('signup_finished');
                        /* end validate_user_signup stage */
                    } else {
                        _e('User registration has been disabled.');
                        ?>
						</div>
						</div>
						<?php 
                        do_action('after_signup_form');
                        get_footer();
                        exit;
                    }
                    break;
                case 'blog-signup':
                    if ($active_signup == 'all' || $active_signup == 'blog') {
                        /* begin validate_blog_signup stage */
                        $result = wpmu_validate_user_signup(isset($_POST['user_name']) ? (string) $_POST['user_name'] : "", isset($_POST['user_email']) ? (string) $_POST['user_email'] : "");
                        extract($result);
                        if ($errors->get_error_code()) {
                            echo "signup_user";
                            signup_user($user_name, $user_email, $errors);
                            do_action('after_signup_form');
                            get_footer();
                            exit;
                        }
                        $result = wpmu_validate_blog_signup(isset($_POST['blogname']) ? (string) $_POST['blogname'] : "", isset($_POST['blog_title']) ? (string) $_POST['blog_title'] : "");
                        extract($result);
                        if ($errors->get_error_code()) {
                            signup_blog($user_name, $user_email, $blogname, $blog_title, $errors);
                            do_action('after_signup_form');
                            get_footer();
                            exit;
                        }
                        // collect meta, commit user to database, send email
                        $meta = array('lang_id' => 1, 'public' => (int) $_POST['blog_public']);
                        wpmu_signup_blog($domain, $path, $blog_title, $user_name, $user_email, apply_filters('add_signup_meta', $meta));
                        // previously, displayed confirm_blog_signup message before signup_finished action
                        do_action('signup_finished');
                        /* end validate_blog_signup stage */
                    } else {
                        _e('Site registration has been disabled.');
                        ?>
						</div>
						</div>
						<?php 
                        do_action('after_signup_form');
                        get_footer();
                        exit;
                    }
                    break;
                default:
                    return;
            }
            /* begin wp-activate page */
            $key = (string) $_REQUEST['key'];
            // wpmu_create_user, wpmu_welcome_user_notification, add_new_user_to_blog, do wpmu_activate_user action
            $result = wpmu_activate_signup($key);
            if (is_wp_error($result)) {
                if ('already_active' == $result->get_error_code() || 'blog_taken' == $result->get_error_code()) {
                    $signup = $result->get_error_data();
                    ?>
					<h2><?php 
                    _e('Your account is now active!');
                    ?>
</h2>
					<?php 
                    echo '<p class="lead-in">';
                    if ($signup->domain . $signup->path == '') {
                        printf(__('Your account has been activated. You may now <a href="%1$s">log in</a> to the site using your chosen username of &#8220;%2$s&#8221;. Please check your email inbox at %3$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%4$s">reset your password</a>.'), network_site_url('wp-login.php', 'login'), $signup->user_login, $signup->user_email, wp_lostpassword_url());
                    } else {
                        printf(__('Your site at <a href="%1$s">%2$s</a> is active. You may now log in to your site using your chosen username of &#8220;%3$s&#8221;. Please check your email inbox at %4$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%5$s">reset your password</a>.'), 'http://' . $signup->domain, $signup->domain, $signup->user_login, $signup->user_email, wp_lostpassword_url());
                    }
                    echo '</p>';
                } else {
                    ?>
					<h2><?php 
                    _e('An error occurred during the activation');
                    ?>
</h2>
					<?php 
                    echo '<p>' . $result->get_error_message() . '</p>';
                }
            } else {
                //TODO: Why not reference $result->blog_id?
                extract($result);
                if (isset($blog_id)) {
                    $url = get_blogaddress_by_id((int) $blog_id);
                }
                $user = get_userdata((int) $user_id);
                ?>
				<h2><?php 
                _e('Your account is now active!');
                ?>
</h2>
				<div id="signup-welcome">
					<p><span class="h3"><?php 
                _e('Username:'******'Password:'******'', 'http')) {
                    ?>
					<p class="view"><?php 
                    printf(__('Your account is now activated. <a href="%1$s">View your site</a> or <a href="%2$s">Log in</a>'), $url, $url . 'wp-login.php');
                    ?>
</p>
				<?php 
                } else {
                    ?>
					<p class="view"><?php 
                    printf(__('Your account is now activated. <a href="%1$s">Log in</a> or go back to the <a href="%2$s">homepage</a>.'), network_site_url('wp-login.php', 'login'), network_home_url());
                    ?>
</p>
				<?php 
                }
            }
            ?>
			</div>
			<script type="text/javascript">
				var key_input = document.getElementById('key');
				key_input && key_input.focus();
			</script>
			<?php 
            get_footer();
            ?>
			<?php 
            exit;
        }
/**
 * Validate new site signup
 *
 * @since MU
 *
 * @return bool True if the site signup was validated, false if error
 */
function validate_blog_signup()
{
    // Re-validate user info.
    $user_result = wpmu_validate_user_signup($_POST['user_name'], $_POST['user_email']);
    $user_name = $user_result['user_name'];
    $user_email = $user_result['user_email'];
    $user_errors = $user_result['errors'];
    if ($user_errors->get_error_code()) {
        signup_user($user_name, $user_email, $user_errors);
        return false;
    }
    $result = wpmu_validate_blog_signup($_POST['blogname'], $_POST['blog_title']);
    $domain = $result['domain'];
    $path = $result['path'];
    $blogname = $result['blogname'];
    $blog_title = $result['blog_title'];
    $errors = $result['errors'];
    if ($errors->get_error_code()) {
        signup_blog($user_name, $user_email, $blogname, $blog_title, $errors);
        return false;
    }
    $public = (int) $_POST['blog_public'];
    $signup_meta = array('lang_id' => 1, 'public' => $public);
    // Handle the language setting for the new site.
    if (!empty($_POST['WPLANG'])) {
        $languages = signup_get_available_languages();
        if (in_array($_POST['WPLANG'], $languages)) {
            $language = wp_unslash(sanitize_text_field($_POST['WPLANG']));
            if ($language) {
                $signup_meta['WPLANG'] = $language;
            }
        }
    }
    /** This filter is documented in wp-signup.php */
    $meta = apply_filters('add_signup_meta', $signup_meta);
    wpmu_signup_blog($domain, $path, $blog_title, $user_name, $user_email, $meta);
    confirm_blog_signup($domain, $path, $blog_title, $user_name, $user_email, $meta);
    return true;
}
    }
    return FALSE;
}
add_filter('wpmu_signup_blog_notification', 'psu_signup_blog_notification', 11, 7);
// we don't want crawlers to index this page, if they ever get here.
function signuppageheaders()
{
    echo "<meta name='robots' content='noindex,nofollow' />\n";
}
add_action('wp_head', 'signuppageheaders');
// put a header on the page
get_header();
/*
	Set the information about the user and his/her new blog.
	Make changes here as appropriate for your site.
*/
$user_email = $username . '@site.org';
/*
	Set the url for the new blog based on the username returned from CAS.
	Underscores aren't allowed in MU blog addresses; 
	You may have to clean your usernames in other ways as well.
*/
$sitename = str_replace('_', '-', $username);
/*
	We can't use the global $domain, it turns out, because it isn't set to the 
	base domain, but to the subdomain of whatever blog the user is currently visiting.
*/
$domain = $sitename . '.blogs.site.org';
// provision it
wpmu_signup_blog($domain, $base, $sitename, $username, $user_email);
wpmu_validate_blog_signup();
Exemple #10
0
 /**
  * Multisite uses code from wp-signup.php
  */
 public function register_user_and_site()
 {
     if (!get_option('users_can_register')) {
         $error = new WP_Error();
         $error->add('users_cannot_register', __('Registration is not enabled for this site.'));
         return $error;
     }
     // support for blog defaults not yet added
     // may not be necessary or approapriate here
     // from wp-signup.php
     // 		$signup_blog_defaults = array(
     // 				'user_name'  => $user_name,
     // 				'user_email' => $user_email,
     // 				'blogname'   => $blogname,
     // 				'blog_title' => $blog_title,
     // 				'errors'     => $errors
     // 		);
     /**
      * Filter the default site creation variables for the site sign-up form.
      *
      * @since 3.0.0
      *
      * @param array $signup_blog_defaults {
      *     An array of default site creation variables.
      *
      *     @type string $user_name  The user username.
      *     @type string $user_email The user email address.
      *     @type string $blogname   The blogname.
      *     @type string $blog_title The title of the site.
      *     @type array  $errors     An array of possible errors relevant to new site creation variables.
      * }
      */
     // 		$filtered_results = apply_filters( 'signup_blog_init', $signup_blog_defaults );
     // 		$user_name = $filtered_results['user_name'];
     // 		$user_email = $filtered_results['user_email'];
     // 		$blogname = $filtered_results['blogname'];
     // 		$blog_title = $filtered_results['blog_title'];
     // 		$errors = $filtered_results['errors'];
     // 		if ( empty($blogname) ) {
     // 			$blogname = $user_name;
     // 		}
     // end blog defaults
     $newblogname = isset($_POST['blogname']) ? strtolower(preg_replace('/^-|-$|[^-a-zA-Z0-9]/', '', $_POST['blogname'])) : null;
     if (is_array(get_site_option('illegal_names')) && isset($newblogname) && in_array($newblogname, get_site_option('illegal_names')) == true) {
         $error = new WP_Error();
         $error->add('illegal_name', __('This site name is not allowed.'));
         return $error;
     }
     if (empty($_POST['user_name']) || empty($_POST['user_email'])) {
         $errors = new WP_Error();
         if (empty($_POST['user_name'])) {
             $errors->add('username_required', __("A username is required."));
         }
         if (empty($_POST['user_email'])) {
             $errors->add('email_required', __("A email is required."));
         }
         return $errors;
     }
     // user should not be logged in when calling this method
     $result = wpmu_validate_user_signup($_POST['user_name'], $_POST['user_email']);
     extract($result);
     if ($errors->get_error_code()) {
         return $errors;
     }
     $user = '';
     if (is_user_logged_in()) {
         $user = wp_get_current_user();
     }
     $result = wpmu_validate_blog_signup($newblogname, $_POST['blog_title'], $user);
     extract($result);
     if ($errors->get_error_code()) {
         return $errors;
     }
     $public = (int) $_POST['blog_public'];
     $meta = array('lang_id' => 1, 'public' => $public);
     /** This filter is documented in wp-signup.php */
     $meta = apply_filters('add_signup_meta', $meta);
     wpmu_signup_blog($domain, $path, $blog_title, $user_name, $user_email, $meta);
     $blog = get_blog_details(array('domain' => $domain, 'path' => $path));
     if ($errors->get_error_code()) {
         return $errors;
     }
     // creates message for user - not necessary
     $message = $this->confirm_blog_signup($domain, $path, $blog_title, $user_name, $user_email, $meta);
     $result = array('message' => $message, 'user_name' => $user_name, 'user_email' => $user_email, 'blogname' => $newblogname, 'blog_title' => $blog_title, 'blog' => $blog);
     $result = array('created' => true, 'site' => $result);
     return $result;
 }