<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>WPMU DEV Community &#187; Topic: Signup Password / WPMU 2.7</title>
		<link>http://premium.wpmudev.org/forums/topic/signup-password-wpmu-27</link>
		<description>WPMU DEV Community &#187; Topic: Signup Password / WPMU 2.7</description>
		<language>en-US</language>
		<pubDate>Fri, 24 May 2013 20:50:34 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.2</generator>
		<atom:link href="http://premium.wpmudev.org/forums/rss/topic/signup-password-wpmu-27" rel="self" type="application/rss+xml" />

		<item>
			<title>Andrew on "Signup Password / WPMU 2.7"</title>
			<link>http://premium.wpmudev.org/forums/topic/signup-password-wpmu-27#post-9513</link>
			<pubDate>Fri, 15 May 2009 17:16:11 +0000</pubDate>
			<dc:creator>Andrew</dc:creator>
			<guid isPermaLink="false">9513@http://premium.wpmudev.org/forums/</guid>
			<description><![CDATA[<p>Hiya,</p>
<blockquote><p>the above code is for the signup plugin to work with BuddyPress. </p></blockquote>
<p>That wasn't mentioned anywhere in your post.</p>
<blockquote><p>Does the plugin work correctly with 2.7.1?</p></blockquote>
<p>The plugin works just fine with WPMU 2.7.1.</p>
<blockquote><p>if not, I would say move the hack to an appropriate place so users can benefit from it. </p></blockquote>
<p>I'm going to leave it here with the note intact.</p>
<p>Thanks,<br />
Andrew
</p>]]></description>
		</item>
		<item>
			<title>videowows on "Signup Password / WPMU 2.7"</title>
			<link>http://premium.wpmudev.org/forums/topic/signup-password-wpmu-27#post-9512</link>
			<pubDate>Fri, 15 May 2009 17:08:13 +0000</pubDate>
			<dc:creator>videowows</dc:creator>
			<guid isPermaLink="false">9512@http://premium.wpmudev.org/forums/</guid>
			<description><![CDATA[<p>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.
</p>]]></description>
		</item>
		<item>
			<title>James Farmer on "Signup Password / WPMU 2.7"</title>
			<link>http://premium.wpmudev.org/forums/topic/signup-password-wpmu-27#post-9496</link>
			<pubDate>Fri, 15 May 2009 03:48:28 +0000</pubDate>
			<dc:creator>James Farmer</dc:creator>
			<guid isPermaLink="false">9496@http://premium.wpmudev.org/forums/</guid>
			<description><![CDATA[<p>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).</p>
<p>Sorry, but we're gonna have to remove the post (for the sake of keeping the forums containing the right advice) :/ Hope that's not too much of a pain... please let me know and I'll edit it out.
</p>]]></description>
		</item>
		<item>
			<title>videowows on "Signup Password / WPMU 2.7"</title>
			<link>http://premium.wpmudev.org/forums/topic/signup-password-wpmu-27#post-9494</link>
			<pubDate>Fri, 15 May 2009 03:33:26 +0000</pubDate>
			<dc:creator>videowows</dc:creator>
			<guid isPermaLink="false">9494@http://premium.wpmudev.org/forums/</guid>
			<description><![CDATA[<p><strong>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</strong></p>
<p>Here's a quick fix for the above problem.<br />
add following function to /wp-signup.php<br />
<pre><code>function confirm_direct_user_signup($user_name, $user_email) {
	?&#62;
	&#60;h2&#62;&#60;?php printf(__(&#39;%s is your new username&#39;), $user_name) ?&#62;&#60;/h2&#62;
	&#60;h3&#62;&#60;?php _e(&#34;&#60;a href=&#34; . site_url( &#39;wp-login.php&#39; ) . &#34;&#62;Click here to login&#60;/a&#62;&#34;) ?&#62;&#60;/h3&#62;
	&#60;?php printf(__(&#39;We have also sent copy of your login details to your inbox at &#60;strong&#62;%1$s&#60;/strong&#62;.&#39;),  $user_email) ?&#62;

	&#60;?php
	do_action(&#39;signup_finished&#39;);
}</code></pre>
<p>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.<br />
<pre><code>$user_password = $_POST[&#39;password_1&#39;];
	wpmu_direct_signup_user($user_name, $user_email, apply_filters( &#34;add_signup_meta&#34;, array() ), $user_password );
	confirm_direct_user_signup($user_name, $user_email);</code></pre>
<p>Open wp-includes/wpmu-functions.php and add the following functions.<br />
<pre><code>function wpmu_direct_signup_user($user, $user_email, $meta= &#39;&#39;, $password) {
	global $wpdb;
	// Format data
	$user = preg_replace( &#34;/\s+/&#34;, &#39;&#39;, sanitize_user( $user, true ) );
	$user_email = sanitize_email( $user_email );
	$key = substr( md5( time() . rand() . $user_email ), 0, 16 );
	$meta = serialize($meta);

	$wpdb-&#62;insert( $wpdb-&#62;signups, array(
		&#39;domain&#39; =&#62; &#39;&#39;,
		&#39;path&#39; =&#62; &#39;&#39;,
		&#39;title&#39; =&#62; &#39;&#39;,
		&#39;user_login&#39; =&#62; $user,
		&#39;user_email&#39; =&#62; $user_email,
		&#39;registered&#39; =&#62; current_time(&#39;mysql&#39;, true),
		&#39;activation_key&#39; =&#62; $key,
		&#39;meta&#39; =&#62; $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-&#62;get_row( $wpdb-&#62;prepare(&#34;SELECT * FROM $wpdb-&#62;signups WHERE activation_key = %s&#34;, $key) );

	if ( empty($signup) )
		return new WP_Error(&#39;invalid_key&#39;, __(&#39;Invalid activation key.&#39;));

	if ( $signup-&#62;active )
		return new WP_Error(&#39;already_active&#39;, __(&#39;The blog is already active.&#39;), $signup);

	$meta = unserialize($signup-&#62;meta);
	$user_login = $wpdb-&#62;escape($signup-&#62;user_login);
	$user_email = $wpdb-&#62;escape($signup-&#62;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);
	else
		$user_already_exists = true;

	if ( ! $user_id )
		return new WP_Error(&#39;create_user&#39;, __(&#39;Could not create user&#39;), $signup);

	$now = current_time(&#39;mysql&#39;, true);

	if ( empty($signup-&#62;domain) ) {
		$wpdb-&#62;update( $wpdb-&#62;signups, array(&#39;active&#39; =&#62; 1, &#39;activated&#39; =&#62; $now), array(&#39;activation_key&#39; =&#62; $key) );
		if ( isset($user_already_exists) )
			return new WP_Error(&#39;user_already_exists&#39;, __(&#39;That username is already activated.&#39;), $signup);
		wpmu_welcome_user_notification($user_id, $password, $meta);
		if ( get_site_option( &#39;dashboard_blog&#39; ) == false ) {
			add_user_to_blog( &#39;1&#39;, $user_id, get_site_option( &#39;default_user_role&#39;, &#39;subscriber&#39; ) );
		} else {
			add_user_to_blog( get_site_option( &#39;dashboard_blog&#39; ), $user_id, get_site_option( &#39;default_user_role&#39;, &#39;subscriber&#39; ) );
		}
		add_new_user_to_blog( $user_id, $user_email, $meta );
		do_action(&#39;wpmu_activate_user&#39;, $user_id, $password, $meta);
		return array(&#39;user_id&#39; =&#62; $user_id, &#39;password&#39; =&#62; $password, &#39;meta&#39; =&#62; $meta);
	}

	wpmu_validate_blog_signup($signup-&#62;domain, $signup-&#62;title);
	$blog_id = wpmu_create_blog($signup-&#62;domain, $signup-&#62;path, $signup-&#62;title, $user_id, $meta, $wpdb-&#62;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&#39;s just set the active flag and instruct the user to reset their password.
		if ( &#39;blog_taken&#39; == $blog_id-&#62;get_error_code() ) {
			$blog_id-&#62;add_data($signup);
			$wpdb-&#62;update( $wpdb-&#62;signups, array(&#39;active&#39; =&#62; 1, &#39;activated&#39; =&#62; $now), array(&#39;activation_key&#39; =&#62; $key) );
		}

		return $blog_id;
	}

	$wpdb-&#62;update( $wpdb-&#62;signups, array(&#39;active&#39; =&#62; 1, &#39;activated&#39; =&#62; $now), array(&#39;activation_key&#39; =&#62; $key) );

	wpmu_welcome_notification($blog_id, $user_id, $password, $signup-&#62;title, $meta);

	do_action(&#39;wpmu_activate_blog&#39;, $blog_id, $user_id, $password, $signup-&#62;title, $meta);

	return array(&#39;blog_id&#39; =&#62; $blog_id, &#39;user_id&#39; =&#62; $user_id, &#39;password&#39; =&#62; $password, &#39;title&#39; =&#62; $signup-&#62;title, &#39;meta&#39; =&#62; $meta);
}</code></pre>
<p>This should work in conjunction with the signup plugin that's available on this site.
</p>]]></description>
		</item>
		<item>
			<title>Ovidiu on "Signup Password / WPMU 2.7"</title>
			<link>http://premium.wpmudev.org/forums/topic/signup-password-wpmu-27#post-6609</link>
			<pubDate>Sat, 21 Feb 2009 15:12:29 +0000</pubDate>
			<dc:creator>Ovidiu</dc:creator>
			<guid isPermaLink="false">6609@http://premium.wpmudev.org/forums/</guid>
			<description><![CDATA[<p>I can confirm this, but anyway it hasn't officially been updated to work with 2.7
</p>]]></description>
		</item>
		<item>
			<title>stankt on "Signup Password / WPMU 2.7"</title>
			<link>http://premium.wpmudev.org/forums/topic/signup-password-wpmu-27#post-6507</link>
			<pubDate>Wed, 18 Feb 2009 07:46:52 +0000</pubDate>
			<dc:creator>stankt</dc:creator>
			<guid isPermaLink="false">6507@http://premium.wpmudev.org/forums/</guid>
			<description><![CDATA[<p>Hi!</p>
<p>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..</p>
<p>What would be the problem? Thanks!
</p>]]></description>
		</item>

	</channel>
</rss>