/**
 * Validate the new user signup
 *
 * @since MU
 *
 * @return bool True if new user signup was validated, false if error
 */
function validate_user_signup()
{
    $result = validate_user_form();
    $user_name = $result['user_name'];
    $user_email = $result['user_email'];
    $errors = $result['errors'];
    if ($errors->get_error_code()) {
        signup_user($user_name, $user_email, $errors);
        return false;
    }
    if ('blog' == $_POST['signup_for']) {
        signup_blog($user_name, $user_email);
        return false;
    }
    /** This filter is documented in wp-signup.php */
    wpmu_signup_user($user_name, $user_email, apply_filters('add_signup_meta', array()));
    confirm_user_signup($user_name, $user_email);
    return true;
}
Example #2
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;
}
Example #3
0
/**
 * 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;
}
        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;
}