Signup Password / WPMU 2.7


I installed WPMU 2.7 together w/ Sign-up Password plugin, but when I registered and typed a password and doesn't save to the database, it still generate a random password..

What would be the problem? Thanks!

  • videowows
    • New Recruit

    WPMU DEV Staff Note - We strongly advise against editing your core code as advised below - the plugin should work just fine with 2.7.1

    Here's a quick fix for the above problem.
    add following function to /wp-signup.php

    function confirm_direct_user_signup($user_name, $user_email) {
    	<h2><?php printf(__('%s is your new username'), $user_name) ?></h2>
    	<h3><?php _e("<a href=" . site_url( 'wp-login.php' ) . ">Click here to login</a>") ?></h3>
    	<?php printf(__('We have also sent copy of your login details to your inbox at <strong>%1$s</strong>.'),  $user_email) ?>

    Add the following before the "return true" i.e. last line of validate_user_signup(). These three lines allow us to get the password from the signup form, skip the email validation and directly activate the user without sending activation confirmation email, send registration/welcome email to the user.

    $user_password = $_POST['password_1'];
    	wpmu_direct_signup_user($user_name, $user_email, apply_filters( "add_signup_meta", array() ), $user_password );
    	confirm_direct_user_signup($user_name, $user_email);

    Open wp-includes/wpmu-functions.php and add the following functions.

    function wpmu_direct_signup_user($user, $user_email, $meta= '', $password) {
    	global $wpdb;
    	// Format data
    	$user = preg_replace( "/\s+/", '', sanitize_user( $user, true ) );
    	$user_email = sanitize_email( $user_email );
    	$key = substr( md5( time() . rand() . $user_email ), 0, 16 );
    	$meta = serialize($meta);
    	$wpdb->insert( $wpdb->signups, array(
    		'domain' => '',
    		'path' => '',
    		'title' => '',
    		'user_login' => $user,
    		'user_email' => $user_email,
    		'registered' => current_time('mysql', true),
    		'activation_key' => $key,
    		'meta' => $meta
    	) );
    	wpmu_direct_activate_signup($key, $password);
    	//no need to send activation email.
    	//wpmu_signup_user_notification($user, $user_email, $key, $meta);
    function wpmu_direct_activate_signup($key, $password) {
    	global $wpdb;
    	$signup = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->signups WHERE activation_key = %s", $key) );
    	if ( empty($signup) )
    		return new WP_Error('invalid_key', __('Invalid activation key.'));
    	if ( $signup->active )
    		return new WP_Error('already_active', __('The blog is already active.'), $signup);
    	$meta = unserialize($signup->meta);
    	$user_login = $wpdb->escape($signup->user_login);
    	$user_email = $wpdb->escape($signup->user_email);
    	wpmu_validate_user_signup($user_login, $user_email);
    	$user_id = username_exists($user_login);
    	if ( ! $user_id )
    		$user_id = wpmu_create_user($user_login, $password, $user_email);
    		$user_already_exists = true;
    	if ( ! $user_id )
    		return new WP_Error('create_user', __('Could not create user'), $signup);
    	$now = current_time('mysql', true);
    	if ( empty($signup->domain) ) {
    		$wpdb->update( $wpdb->signups, array('active' => 1, 'activated' => $now), array('activation_key' => $key) );
    		if ( isset($user_already_exists) )
    			return new WP_Error('user_already_exists', __('That username is already activated.'), $signup);
    		wpmu_welcome_user_notification($user_id, $password, $meta);
    		if ( get_site_option( 'dashboard_blog' ) == false ) {
    			add_user_to_blog( '1', $user_id, get_site_option( 'default_user_role', 'subscriber' ) );
    		} else {
    			add_user_to_blog( get_site_option( 'dashboard_blog' ), $user_id, get_site_option( 'default_user_role', 'subscriber' ) );
    		add_new_user_to_blog( $user_id, $user_email, $meta );
    		do_action('wpmu_activate_user', $user_id, $password, $meta);
    		return array('user_id' => $user_id, 'password' => $password, 'meta' => $meta);
    	wpmu_validate_blog_signup($signup->domain, $signup->title);
    	$blog_id = wpmu_create_blog($signup->domain, $signup->path, $signup->title, $user_id, $meta, $wpdb->siteid);
    	// TODO: What to do if we create a user but cannot create a blog?
    	if ( is_wp_error($blog_id) ) {
    		// If blog is taken, that means a previous attempt to activate this blog failed in between creating the blog and
    		// setting the activation flag.  Let's just set the active flag and instruct the user to reset their password.
    		if ( 'blog_taken' == $blog_id->get_error_code() ) {
    			$wpdb->update( $wpdb->signups, array('active' => 1, 'activated' => $now), array('activation_key' => $key) );
    		return $blog_id;
    	$wpdb->update( $wpdb->signups, array('active' => 1, 'activated' => $now), array('activation_key' => $key) );
    	wpmu_welcome_notification($blog_id, $user_id, $password, $signup->title, $meta);
    	do_action('wpmu_activate_blog', $blog_id, $user_id, $password, $signup->title, $meta);
    	return array('blog_id' => $blog_id, 'user_id' => $user_id, 'password' => $password, 'title' => $signup->title, 'meta' => $meta);

    This should work in conjunction with the signup plugin that's available on this site.

  • James Farmer
    • CEO (of WPMU DEV, honest)

    Edit - whoops, my bad, we've taken another looks at it and the signup should run just fine with 2.7.1... and this advice is for users to hack their core (not something we recommend).

    Sorry, but we're gonna have to remove the post (for the sake of keeping the forums containing the right advice) :disappointed: Hope that's not too much of a pain... please let me know and I'll edit it out.

  • videowows
    • New Recruit

    james - the above code is for the signup plugin to work with BuddyPress. Does the plugin work correctly with 2.7.1? If yes, then feel free to remove the post comment, if not, I would say move the hack to an appropriate place so users can benefit from it.

  • Andrew
    • Champion of Loops


    the above code is for the signup plugin to work with BuddyPress.

    That wasn't mentioned anywhere in your post.

    Does the plugin work correctly with 2.7.1?

    The plugin works just fine with WPMU 2.7.1.

    if not, I would say move the hack to an appropriate place so users can benefit from it.

    I'm going to leave it here with the note intact.


Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.