Skip to content

Instantly share code, notes, and snippets.

@stephanieleary
Created October 11, 2016 15:51
Show Gist options
  • Save stephanieleary/e4d502fe8aaa8893e8002810071324d7 to your computer and use it in GitHub Desktop.
Save stephanieleary/e4d502fe8aaa8893e8002810071324d7 to your computer and use it in GitHub Desktop.
Give new network users a default role on the main site
<?php
function tees_add_network_default_roles( $user_id ) {
if ( is_main_site() && !is_user_member_of_blog( $user_id ) )
add_user_to_blog( get_current_blog_id(), $user_id, 'subscriber' );
}
add_action( 'wpmu_activate_user', 'tees_add_network_default_roles', 10, 1 );
add_action( 'wpmu_new_user', 'tees_add_network_default_roles', 10, 1 );
add_action( 'user_register', 'tees_add_network_default_roles', 10, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment