访问/ newbloguser / {key} /,将新用户添加到博客。

原型

maybe_add_existing_user_to_blog()

描述

这仅在将用户的详细信息保存为键入为“new_user_ {key}”的选项时才有效,其中“{key}”是为要添加的用户生成的哈希,例如当用户通过常规WP添加时被邀请用户界面。

源文件

路径:wp-includes/ms-functions.php

<?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 ) );
}
...
?>

其他

英文文档:https://developer.wordpress.org/reference/functions/maybe_add_existing_user_to_blog/