Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: bbp_add_user_subscription help

@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;
}
?>
Skip to toolbar