Skip to content

@ntwb /ntwb_bbpress_subscribe_all_users_to_a_forum.php secret
Last active

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
<?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.