首页>文档>Wordpress开发文档>Wordpress 函数>maybe_add_existing_user_to_blog()

maybe_add_existing_user_to_blog()

通过访问/new blog user/{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:211408
0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索