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.

The details must at least contain values for the following keys:

  • $details['user_id'] - (integer) the ID of the user being added to the blog
  • $details['role'] - (string) the role to be assigned to the user in the blog

maybe_add_existing_user_to_blog() 描述

用法

<?php maybe_add_existing_user_to_blog(); ?>

maybe_add_existing_user_to_blog() 用法

参数

This function does not accept parameters, pertinent information is passed by saving it in the options as described in Description. This information is then removed from options once the data has been extracted.

maybe_add_existing_user_to_blog() 参数

示例

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */

maybe_add_existing_user_to_blog() 示例

历史

添加于 版本: MU

maybe_add_existing_user_to_blog() 历史

源文件

maybe_add_existing_user_to_blog() 函数的代码位于 wp-includes/ms-functions.php

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */
/**
 * 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 ) );
}

maybe_add_existing_user_to_blog() 源文件

相关