So, I've found the action 'add_user_to_blog', which takes 3 arguments. I need to change the value of one of the arguments, but I am not sure how to get at particular arguments from my plugin.
For instance, here is add_user_to_blog
function add_user_to_blog( $blog_id, $user_id, $role ) {
switch_to_blog($blog_id);
$user = new WP_User($user_id);
if ( empty($user) )
return new WP_Error('user_does_not_exist', __('That user does not exist.'));
if ( !get_usermeta($user_id, 'primary_blog') ) {
update_usermeta($user_id, 'primary_blog', $blog_id);
$details = get_blog_details($blog_id);
update_usermeta($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;
}
So I need to get at $role. Does my plugin then have to be set up like this:
function change_user_role_to_something_else($blog_id, $user_id, $role)
{
//do stuff
}
and then I hook in like this:
add_action('add_user_to_blog', 'change_user_role_to_something_else', 1, 3);
I guess I am confused by how arguments are passed back and forth from hooks. The codex is mum, all it says is some hooks pass more arguments than others.
Thanks,
Joseph