add_user_to_blog [ WordPress Function ]
add_user_to_blog ( $blog_id, $user_id, $role )
| Parameters: |
|
| Returns: |
|
| Defined at: |
|
Soorgelijke functies: add_new_user_to_blog, add_existing_user_to_blog, get_users_of_blog, add_user_meta, maybe_add_existing_user_to_blog
Add a user to a blog.
Use the 'add_user_to_blog' action to fire an event when users are added to a blog.
Source
<?php
function add_user_to_blog( $blog_id, $user_id, $role ) {
switch_to_blog($blog_id);
$user = new WP_User($user_id);
if ( ! $user->exists() ) {
restore_current_blog();
return new WP_Error('user_does_not_exist', __('That user does not exist.'));
}
if ( !get_user_meta($user_id, 'primary_blog', true) ) {
update_user_meta($user_id, 'primary_blog', $blog_id);
$details = get_blog_details($blog_id);
update_user_meta($user_id, 'source_domain', $details->domain);
}
$user->set_role($role);
do_action('add_user_to_blog', $user_id, $role, $blog_id);
wp_cache_delete( $user_id, 'users' );
restore_current_blog();
return true;
}
?>
Examples [ wp-snippets.com ]
Top Google zoekresultaten
- WPMU Functions/add user to blog « WordPress Codex
Description. Grants the specified user permissions of the specified role on the specified blog. Parameters. $blog_id: (integer) (required) The ID of the blog to ...
codex.wordpress.org - Function Reference/add user to blog « WordPress Codex
Description. Associates a user to a blog, with the ability to set access permission. Usage. <?php add_user_to_blog( $blog_id, $user_id, $role ) ?> Parameters ...
codex.wordpress.org - WordPress › Support » add_user_to_blog not working
I have a function that create a new blog and adds a user as an author to that blog. The add_user_to_blog function is not adding the new user to the blog and not ...
wordpress.org - add_user_to_blog Wordpress hook details -- Adam Brown, BYU ...
WordPress hook directory add_user_to_blog. WordPress version history for add_user_to_blog. This database has information for all major versions from WP ...
adambrown.info