maybe_add_existing_user_to_blog() - WordPress 函数参考中文文档

返回介绍

maybe_add_existing_user_to_blog()

发布于 2017-07-23 字数2031 浏览 1128 评论 0

maybe_add_existing_user_to_blog()

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.


源代码

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 &rsaquo; Success' ), array( 'response' => 200 ) );
}

更新日志

Version 描述
MU Introduced.

相关函数

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()

上一篇:add_existing_user_to_blog()

下一篇:add_feed()

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!