Skip to:
Content
Pages
Categories
Search
Top
Bottom

Can you make a role to subscribe a forum?


  • madflute
    Participant

    @madflute

    Hi, I need to make all the 500+ Subscriber role users subscribe to the Announcement forum as well as the General Discussion forum in batch. Is it possible?
    Thank you.

Viewing 9 replies - 1 through 9 (of 9 total)

  • Robin W
    Moderator

    @robin-w

    I think this has what you need

    bbPress Toolkit


    madflute
    Participant

    @madflute

    Hmmm, I do have this plugin installed but couldn’t find the way. I need to go over the documentation again. Thank you.


    Robin W
    Moderator

    @robin-w

    just looked, yes that seems to only apply to new users


    madflute
    Participant

    @madflute

    Yup, I already have that option turned on. Now I still don’t know what to do with 500+ Subscribers who are not subscribed to the forums. Any ideas would be appreciated.


    Robin W
    Moderator

    @robin-w

    This code (untested) should subscribe all current users to forum ID 3

    $list = get_users();
    if (empty (get_option ('rew_done')) {
    	foreach ($list as $user) {
    		$user_id = $user=>ID ;
    		$forum_id = 3 ;
    		bbp_add_user_forum_subscription( $user_id, $forum_id ) ;
    	}
    	update_option ('rew_done' , 'done' ) ;
    }

    Put this in your child theme’s function file – or use
    https://en-gb.wordpress.org/plugins/code-snippets/ and load a page, then remove it


    madflute
    Participant

    @madflute

    Thank you so much for the snippets. I am no developer and have been struggling with this, to be honest.

    I think line 2 is missing a closing ‘)’ and
    Getting a parse error on line 4. Is ‘=>’ supposed to be ‘->’ or something else is upsetting the parser? Any help would be appreciated.


    Robin W
    Moderator

    @robin-w

    agree line 2, and line 4 should be

    $user_id = $user->ID ;


    madflute
    Participant

    @madflute

    Thank you! I just ran it and worked beautifully (as far as I can tell)!


    Robin W
    Moderator

    @robin-w

    great

Viewing 9 replies - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.
Skip to toolbar