wpmu_signup_user

函数
wpmu_signup_user ( $user, $user_email, $meta = array() )
参数
  • (string) $user The user's requested login name.
    Required:
  • (string) $user_email The user's email address.
    Required:
  • (array) $meta Optional. Signup meta data. Default empty array.
    Required:
    Default: array()
定义位置
相关方法
signup_userwpmu_signup_blogwpmu_signup_stylesheetwpmu_signup_user_notificationwp_insert_user
引入
-
弃用
-

wpmu_signup_user – 此函数在网络中注册一个新的用户帐户。

记录用户的注册信息,以便将来激活。

这个功能在用户注册开放但新网站注册未开放时使用。

function wpmu_signup_user( $user, $user_email, $meta = array() ) {
	global $wpdb;

	// Format data.
	$user       = preg_replace( '/s+/', '', sanitize_user( $user, true ) );
	$user_email = sanitize_email( $user_email );
	$key        = substr( md5( time() . wp_rand() . $user_email ), 0, 16 );

	/**
	 * Filters the metadata for a user signup.
	 *
	 * The metadata will be serialized prior to storing it in the database.
	 *
	 * @since 4.8.0
	 *
	 * @param array  $meta       Signup meta data. Default empty array.
	 * @param string $user       The user's requested login name.
	 * @param string $user_email The user's email address.
	 * @param string $key        The user's activation key.
	 */
	$meta = apply_filters( 'signup_user_meta', $meta, $user, $user_email, $key );

	$wpdb->insert(
		$wpdb->signups,
		array(
			'domain'         => '',
			'path'           => '',
			'title'          => '',
			'user_login'     => $user,
			'user_email'     => $user_email,
			'registered'     => current_time( 'mysql', true ),
			'activation_key' => $key,
			'meta'           => serialize( $meta ),
		)
	);

	/**
	 * Fires after a user's signup information has been written to the database.
	 *
	 * @since 4.4.0
	 *
	 * @param string $user       The user's requested login name.
	 * @param string $user_email The user's email address.
	 * @param string $key        The user's activation key.
	 * @param array  $meta       Signup meta data. Default empty array.
	 */
	do_action( 'after_signup_user', $user, $user_email, $key, $meta );
}

常见问题

FAQs
查看更多 >