Viewing 1 replies (of 1 total)
  • Thread Starter afmelsaidy

    (@afmelsaidy)

    The code I used but not worked :

    add_action('wp','add_current_user_to_blog',10);
    
    function add_current_user_to_blog(){
    	if(!is_user_logged_in())
    		return false;
    	global $current_user, $blog_id;
        switch_to_blog(1); //get role from main blog
        $user_Role = ($current_user->data->wp_capabilities);
    	$add_Role = key($user_Role);
        restore_current_blog();
    	if (!is_blog_user()) //check for current membership
    		add_user_to_blog($blog_id, $current_user->ID, $add_Role); //copy to current blog so roles work
    }
Viewing 1 replies (of 1 total)
  • The topic ‘add users to all sites using the their same role’ is closed to new replies.