Last active
August 29, 2015 14:02
-
-
Save ntwb/2d84795753d468069c36 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
<?php | |
/* | |
Plugin Name: bbPress - Custom subscribe all users to a forum | |
Plugin URI: https://gist.github.com/ntwb/2d84795753d468069c36 | |
Description: bbPress - Custom subscribe all users to a forum | |
Version: 0.1 | |
Author: Stephen Edgar - Netweb | |
Author URI: http://netweb.com.au | |
*/ | |
// The forum ID | |
$forum_id = 43989; | |
// Get the array of ALL users | |
$users = get_users(); | |
// Make sure it is a valid forum ID | |
$forum = bbp_get_forum( $forum_id ); | |
if ( empty( $forum ) ) { | |
echo '<pre> Forum ID ' . $forum_id . ' is not valid</pre>'; | |
return false; | |
} | |
// Loop through each usser and subscribe to the forum | |
foreach ( $users as $user ) { | |
bbp_add_user_forum_subscription( $user->ID, $forum_id ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment