Advertisements

maybe_add_existing_user_to_blog

Definition:
function 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.

Source code

function maybe_add_existing_user_to_blog() {

	if ( false === strpos( $_SERVER[ 'REQUEST_URI' ], '/newbloguser/' ) )

		return false;



	$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>.'), site_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.'), site_url(), admin_url() ), __('Success') );

}

2327

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: