返回介绍

wpmu_signup_user()

发布于 2017-09-11 11:18:57 字数 3241 浏览 987 评论 0 收藏 0

wpmu_signup_user( string $user,  string $user_email,  array $meta = array() )

Record user signup information for future activation.


description

This function is used when user registration is open but new site registration is not.


参数

$user

(string) (Required) The user's requested login name.

$user_email

(string) (Required) The user's email address.

$meta

(array) (Optional) Signup meta data.

Default value: array()


源代码

File: wp-includes/ms-functions.php

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 );
}

更新日志

Versiondescription
MUIntroduced.

相关函数

Uses

  • wp-includes/ms-functions.php: signup_user_meta
  • wp-includes/ms-functions.php: after_signup_user
  • wp-includes/formatting.php: sanitize_email()
  • wp-includes/formatting.php: sanitize_user()
  • wp-includes/pluggable.php: wp_rand()
  • wp-includes/functions.php: current_time()
  • wp-includes/plugin.php: apply_filters()
  • wp-includes/plugin.php: do_action()
  • wp-includes/wp-db.php: wpdb::insert()
  • Show 4 more uses Hide more uses

Used By

  • wp-signup.php: validate_user_signup()

User Contributed Notes

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文