Skip to:
Content
Pages
Categories
Search
Top
Bottom

Subforum Function Stopped Working

  • @aprilschmitt27

    Participant

    Hello,

    My Versions:
    WP 5.7.2
    bbPress 2.6.6
    BuddyPress 8.0.0

    HOME

    This custom function stopped working fully when bbPress changed tables from usermeta to postmeta. Particularly, new users are no longer automatically subscribed to subforums. (We don’t use Groups yet, so I don’t know if that works or not.) Any help would be very greatly appreciated!

    /** GROUP AND FORUM SUBSCRIPTIONS
    * SUBSCRIBE NEW USERS TO GROUPS AND FORUMS
    * This critical code subscribes new users to BuddyPress Groups and bbPress Forums,
    * according to corresponding xProfile interest registration user choices!
    * “Add to BuddyPress groups and forums (including sub-forums) based on xProfile checkbox selection”
    * “add-to-buddypress-groups-based-on-xprofile-selection-upon-activation.php”
    * Author: Harsha Venkatesh (“Greathmaster”, formerly of Paid Memberships Pro)
    */

    //Subscribe a user to a group
    function my_bp_core_activated_user($user_id)
    {

    $groups = array(2 => “HIKING”,
    3 => “PADDLING”,
    4 => “CYCLING”,
    5 => “SKIING”,);

    $forums = array(“HIKING” => 7142,
    “PADDLING” => 7145,
    “CYCLING” => 7147,
    “SKIING” => 7066);

    $selected_groups = xprofile_get_field_data(‘149’, $user_id);

    if(!empty($selected_groups))
    {
    foreach($groups as $group_id => $group_name)
    {
    if(in_array($group_name, $selected_groups))
    {
    groups_join_group($group_id, $user_id );
    //bbp_add_user_forum_subscription( $user_id, $forums[$group_name] );
    subscribe_to_forums($user_id, $forums[$group_name]);
    }
    }
    }

    $overall_group_id = 1;
    $overall_forum_id = 7133;

    groups_join_group($overall_group_id, $user_id );
    //bbp_add_user_forum_subscription( $user_id, $overall_forum_id);
    subscribe_to_forums($user_id, $overall_forum_id);
    }

    //Subscribe a user to a forum and it’s sub forums
    function subscribe_to_forums($user_id, $forum_id)
    {
    //subscribe to the parent forum
    bbp_add_user_forum_subscription( $user_id, $forum_id);

    //subscribe to sub forums (if they exist)
    if (bbp_get_forum_subforum_count( $forum_id ) > 0)
    {
    $sub_forums = bbp_forum_get_subforums($forum_id);

    foreach($sub_forums as $sub_forum)
    {
    bbp_add_user_forum_subscription( $user_id, $sub_forum->ID);
    }
    }
    }

    function my_init()
    {
    add_action(‘bp_core_activated_user’, ‘my_bp_core_activated_user’,15, 1);
    }

    add_action(‘init’, ‘my_init’);

    ~end

Viewing 11 replies - 1 through 11 (of 11 total)
  • @aprilschmitt27

    Participant

    Hello,

    I realize that this great plugin is supported by an all volunteer group. But it’s been 4 months without even a reply. I’m still holding out hope that someone has any ideas to try to get this script working again.

    Regards,
    ~April

    @robin-w

    Moderator

    just looked at this – sorry, as you say I don’t get to every item, and this is bespoke code which means something to someone, but without a heavy investment of time, it is hard to debug why it is not working 🙂

    the function bbp_add_user_forum_subscription is still valid, and should work fine, so the actual change to the way bbpress works should not affect it.

    I have little knowledge of buddypress, so I cannot say whether that code is still valid.

    Have you turned debugging on ? and is it showing anything ?

    @robin-w

    Moderator

    ps – I presume you have a function

    groups_join_group but have not shown it for simplicity ?

    @aprilschmitt27

    Participant

    Robin W,

    Thank you very much for volunteering some thoughts. Especially that you indicating that changes this year haven’t affected the bbp_add_user_forum_subscription function. And it appears that groups_join_group is a BuddyPress function. Your reminder to turn on the debug was priceless. There was only one, unrelated notice.

    I rechecked the Developer’s (Harsha Vetkatesh’s) code online and realized that he had added an updated version! At https://gist.github.com/greathmaster/e67f1ae0feb28c9ab3521b404c8e0544. I added it into a staging copy and it threw a specific error. I’m going to see if I can contact him.

    Thanks again for the Forum. Our trail club uses it very frequently.

    Best Regards,
    ~April

    @robin-w

    Moderator

    great – glad to have been a small help

    @aprilschmitt27

    Participant

    Although I do not see it here, I received the following email:

    “hardep457 wrote:
    Thanks for posting this, I also face same problem till now.
    Post Link: https://bbpress.org/forums/topic/subforum-function-stopped-working/#post-224077”

    hardep457, I was unable to reach the person who created the original script. If you have an even remotely possible solution, it would be super awesome if you could share it.

    Regards,
    ~April

    @robin-w

    Moderator

    that post was a spam post, so I deleted it.

    @aprilschmitt27

    Participant

    Thank you Robin.

    @robin-w

    Moderator

    🙂

    @aprilschmitt27

    Participant

    This topic has been resolved! We discovered what was causing this problem. It was not any custom code or plugin update issue. It was simply that I had changed the bbPress Forum > Visibility from “public” to “private”. Evidentially this prevents a plugin (like bbPress Toolkit) or custom code (like ours) from accessing the information.

    @robin-w

    Moderator

    🙂

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Subforum Function Stopped Working’ is closed to new replies.
Skip to toolbar