Last active

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View ntwb_bbpress_subscribe_all_users_to_a_forum.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
<?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
Something went wrong with that request. Please try again.