Skip to content

Instantly share code, notes, and snippets.

@landbryo
Created April 25, 2019 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save landbryo/0ecc572a105ed813e076ba3c343f50bf to your computer and use it in GitHub Desktop.
Save landbryo/0ecc572a105ed813e076ba3c343f50bf to your computer and use it in GitHub Desktop.
/**
* 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