Created
October 11, 2016 15:51
-
-
Save stephanieleary/e4d502fe8aaa8893e8002810071324d7 to your computer and use it in GitHub Desktop.
Give new network users a default role on the main site
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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