Skip to content

Instantly share code, notes, and snippets.

@ntwb
Last active August 29, 2015 14:02
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 ntwb/2d84795753d468069c36 to your computer and use it in GitHub Desktop.
Save ntwb/2d84795753d468069c36 to your computer and use it in GitHub Desktop.
<?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