jrb9406 (@jrb9406)

Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • @jrb9406

    Participant

    Ok, I’ve been working at this all day (really several weeks) and here’s what I learned.

    bbp_add_user_forum_subscription requires user ID which must be obtained by doing

    $user_idd = bbp_get_user_id(0,FALSE,TRUE);

    these will not work:

    $user_idd = bbp_get_user_id()
    $user_idd = bbp_get_user_id(0,TRUE,FALSE)

    (note that I changed the variable from $user_id so as to not double define)

    This works. The working php code is below.

    <?php
    
    if (isset($_POST[‘action’])) {
    $forum = $_POST[‘action’];
    $forumint = 0 + $forum;
    $user_idd = bbp_get_user_id(0,FALSE,TRUE);
    $subs=bbp_is_user_subscribed_to_forum($user_idd, $forum);
    if($subs==false) {
    //if user not subscribed, then subscribe
    $add=bbp_add_user_forum_subscription( $user_idd, $forumint );
    }
    else {
    $rmv=bbp_remove_user_forum_subscription( $user_idd, $forumint );
    }
    exit;
    }
    ?>

    @jrb9406

    Participant

    sorry, one more edit to hopefully help. With the script below, it does not subscribe or unsubscribe from the forum, but when I execute the code and check my subscriptions page (from profile), the titles of the subscribed forums are removed, but the row for the forum remains (ie. when I click subscribe, my subscriptions page shows titles, when I click unsubscribe, the subscriptions page does not show the title for the forum I tried to unsubscribe to, but it shows the number of topics, posts, etc.).

    <?php
    if (isset($_POST[‘action’])) {
    $forum = $_POST[‘action’];
    $forumint = 0 + $forum;
    $user_id = bbp_get_user_id();
    $subs=bbp_is_user_subscribed_to_forum($user_id, $forum);
    if($subs==false) {
    //if user not subscribed, then subscribe
    $add=bbp_add_user_forum_subscription( $user_id, $forumint );
    $add2=bbp_add_user_subscription( $user_id, $forumint);
    }
    else {
    $rmv=bbp_remove_user_forum_subscription( $user_id, $forumint );
    $rmv=bbp_remove_user_subscription( 0, 79 );
    $rmv2=bbp_remove_user_subscription( $user_id, $forumint);
    }
    echo ‘forum ‘;
    var_dump ($forum);
    echo ‘subscribed ‘;
    var_dump ($subs);
    echo ‘add ‘;
    var_dump ($add);
    echo ‘remove ‘;
    var_dump ($rmv);
    echo ‘foruminteger ‘;
    var_dump ($forumint);
    echo ‘userid ‘;
    var_dump ($user_id);
    exit;
    }
    ?>

    @jrb9406

    Participant

    EDIT:
    Also tried bbp_remove_user_forum_subscription and bbp_add_user_forum_subscription with same results.

    As I understand it, it should return true if the user was subscribed/unsubscribed.

    In reply to: Manage Subscriptions?

    @jrb9406

    Participant

    Sorry, I don’t mean to bump, but does anyone know where I could start? I know the page for each forum has a subscribe/unsubscribe button that I’m basically looking to replicate.

    I figured out that bbpress makes a link to subscribe/unsubscribe from forums, and depending on whether the user is already subscribed, bbpress shows the appropriate link. Where I’m having trouble is how to determine if the user is subscribed to a forum, and getting the link to update accordingly.

    I’m not looking for someone to do this for me for free. I’m just looking for some direction on where to look/what to try. Thanks in advance.

    In reply to: Manage Subscriptions?

    @jrb9406

    Participant

    Thanks!

    I’ve been working on some code to do this. I just figured someone might have thought of developing a plugin for it.

    I haven’t done html coding in 15 years, and I’m just picking up css and php. I guess it’s a learning experience.

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