返回介绍

wpmu_create_user()

发布于 2017-09-11 11:18:12 字数 2535 浏览 985 评论 0 收藏 0

wpmu_create_user( string $user_name,  string $password,  string $email )

Create a user.


description

This function runs when a user self-registers as well as when a Super Admin creates a new user. Hook to ‘wpmu_new_user’ for events that should affect all new users, but only on Multisite (otherwise use {@see’user_register’}).


参数

$user_name

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

$password

(string) (Required) The new user's password.

$email

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


返回值

(int|false) Returns false on failure, or int $user_id on success


源代码

File: wp-includes/ms-functions.php

function wpmu_create_user( $user_name, $password, $email ) {
	$user_name = preg_replace( '/\s+/', '', sanitize_user( $user_name, true ) );

	$user_id = wp_create_user( $user_name, $password, $email );
	if ( is_wp_error( $user_id ) )
		return false;

	// Newly created users have no roles or caps until they are added to a blog.
	delete_user_option( $user_id, 'capabilities' );
	delete_user_option( $user_id, 'user_level' );

	/**
	 * Fires immediately after a new user is created.
	 *
	 * @since MU
	 *
	 * @param int $user_id User ID.
	 */
	do_action( 'wpmu_new_user', $user_id );

	return $user_id;
}

更新日志

Versiondescription
MUIntroduced.

相关函数

Uses

  • wp-includes/formatting.php: sanitize_user()
  • wp-includes/plugin.php: do_action()
  • wp-includes/user.php: wp_create_user()
  • wp-includes/user.php: delete_user_option()
  • wp-includes/ms-functions.php: wpmu_new_user
  • wp-includes/load.php: is_wp_error()
  • Show 1 more use Hide more uses

Used By

  • wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php: WP_REST_Users_Controller::create_item()
  • wp-includes/ms-functions.php: wpmu_activate_signup()

User Contributed Notes

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

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

发布评论

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