maybe_add_existing_user_to_blog()

maybe_add_existing_user_to_blog() 通过访问/new blog user/{k…

maybe_add_existing_user_to_blog()

通过访问/new blog user/{key}/将新用户添加到博客。
Add a new user to a blog by visiting /newbloguser/{key}/.

目录锚点:#说明#返回#源码


说明(Description)

只有当用户的详细信息被保存为键入“new_uuser{key}”的选项时,这才起作用,其中“{key}”是为要添加的用户生成的哈希值,就像通过常规WP Add用户界面邀请用户一样。


返回(Return)

无返回值


源码(Source)

/**
 * Add a new user to a blog by visiting /newbloguser/username/.
 *
 * This will only work when the user's details are saved as an option
 * keyed as 'new_user_x', where 'x' is the username of the user to be
 * added, as when a user is invited through the regular WP Add User interface.
 *
 * @since MU
 */
function maybe_add_existing_user_to_blog() {
	if ( false === strpos( $_SERVER[ 'REQUEST_URI' ], '/newbloguser/' ) )
		return;

	$parts = explode( '/', $_SERVER[ 'REQUEST_URI' ] );
	$key = array_pop( $parts );

	if ( $key == '' )
		$key = array_pop( $parts );

	$details = get_option( 'new_user_' . $key );
	if ( !empty( $details ) )
		delete_option( 'new_user_' . $key );

	if ( empty( $details ) || is_wp_error( add_existing_user_to_blog( $details ) ) )
		wp_die( sprintf(__('An error occurred adding you to this site. Back to the homepage.'), home_url() ) );

	wp_die( sprintf( __( 'You have been added to this site. Please visit the homepage or log in using your username and password.' ), home_url(), admin_url() ), __( 'WordPress › Success' ), array( 'response' => 200 ) );
}
更新版本 源码位置 使用 被使用
MU (3.0.0) wp-includes/ms-functions.php:2114 0 8
类别:WordPress 函数手册

本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。

评论 (0)COMMENT

登录 账号发表你的看法,还没有账号?立即免费 注册