maybe_add_existing_user_to_blog
Add a new user to a blog by visiting /newbloguser/username/.
Description
maybe_add_existing_user_to_blog();
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.
Usage
if ( !function_exists( 'maybe_add_existing_user_to_blog' ) ) { require_once ABSPATH . WPINC . '/ms-functions.php'; } // NOTICE! Understand what this does before running. $result = maybe_add_existing_user_to_blog();
Defined (1)
The function is defined in the following location(s).
- /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 ) ) )
- }