返回介绍

maybe_add_existing_user_to_blog()

发布于 2017-07-23 16:05:52 字数 2034 浏览 1262 评论 0 收藏 0

maybe_add_existing_user_to_blog()

Add a new user to a blog by visiting /newbloguser/username/.


description

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.


源代码

File: wp-includes/ms-functions.php

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 <a href="%s">homepage</a>.'), home_url() ) );

	wp_die( sprintf( __( 'You have been added to this site. Please visit the <a href="%s">homepage</a> or <a href="%s">log in</a> using your username and password.' ), home_url(), admin_url() ), __( 'WordPress › Success' ), array( 'response' => 200 ) );
}

更新日志

Versiondescription
MUIntroduced.

相关函数

Uses

  • wp-includes/l10n.php:__()
  • wp-includes/functions.php:wp_die()
  • wp-includes/link-template.php:admin_url()
  • wp-includes/link-template.php:home_url()
  • wp-includes/option.php:delete_option()
  • wp-includes/option.php:get_option()
  • wp-includes/ms-functions.php:add_existing_user_to_blog()
  • wp-includes/load.php:is_wp_error()

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

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

发布评论

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