Created
April 25, 2019 15:53
-
-
Save landbryo/0ecc572a105ed813e076ba3c343f50bf to your computer and use it in GitHub Desktop.
This file contains 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
/** | |
* Assign users to forums upon registration | |
*/ | |
function sc_user_activate_forum( $user_id ) { | |
$current_user = get_user_by( 'ID', $user_id ); | |
// Subscribe to forums in listed IDs | |
if ( groups_is_user_member( $user_id, 7 ) ) { | |
$forum_ids = array( | |
997, | |
1070, | |
1192, | |
1194, | |
1196 | |
); | |
foreach ( $forum_ids as $forum_id ) { | |
bbp_add_user_subscription( $user_id, $forum_id ); | |
} | |
// Grant access to view hidden forums | |
$current_user->add_cap( 'read_hidden_forums', true ); | |
} | |
} | |
add_action( 'bp_core_activated_user', 'sc_user_activate_forum', 1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment