Search Results for 'code'
-
Search Results
-
Topic: Help in code modification
Hello all,
I wanted to seek help in modifying the following piece of code. I have a site with buddypress groups inside which I have bbpress forums for the respective groups. I want the users of the group to be automatically subscribed to the forums within that group. I tried the following code:
add_filter( 'bbp_get_user_subscribe_link', 'invert_get_user_subscribe_link', 10, 4 ); //invert forum subscription add_filter( 'bbp_is_user_subscribed_to_forum', 'invert_is_user_subscribed_to_forum', 10, 4 ); //invert forum subscription add_filter( 'bbp_get_forum_subscribers', 'invert_get_forum_subscribers' ); //invert forum subscription add_filter( 'bbp_is_user_subscribed', 'invert_is_user_subscribed', 10, 4 ); //invert forum subscription function invert_is_user_subscribed($retval, $user_id, $object_id, $subscribed_ids) { if (get_post_type( $object_id ) == bbp_get_forum_post_type()) return !$retval; else return $retval; } function strContains($needle, $haystack) { if (strpos($haystack, $needle) !== false) { return true; } else { return false; } } function invert_get_user_subscribe_link ($html, $r, $user_id, $topic_id) { if (strContains( "bbp_unsubscribe", $html )) { $html = str_replace("bbp_unsubscribe", "bbp_subscribe", $html); } else { $html = str_replace("bbp_subscribe", "bbp_unsubscribe", $html); } return $html; } function invert_get_forum_subscribers( $users ) { $args = array('fields' => 'id'); $all_users = get_users($args); $send_to_users = array_diff($all_users, $users); return $send_to_users; } function invert_is_user_subscribed_to_forum( $retval, $user_id, $forum_id, $subscribed_ids ) { return !$retval; }But there is a problem. Using the following code leads to the user getting subscribed to all the forums of all the groups (even those which they aren’t a part of). I just want them to be automatically subscribed to those forum topics created inside the group which they are a part of. Kindly help me in getting this right.
Thanks!
WP version: 4.3.1 multisite
BuddyPress version: 2.3.3
bbPress version: 2.5.8I have been trying to migrate BuddyPress legacy forums to bbPress following the instructions on this link https://codex.buddypress.org/getting-started/guides/migrating-from-old-forums-to-bbpress-2/
But the migration/import is not going well, after the process:
1) Topics are missing
2) Replies are missingAnd during the process I can see “No topics to convert”, No replies to convert.
When I check the database I can see wp_bb_topics etc.
What am I doing wrong?
Thank you in advance.
I’m trying to follow https://codex.bbpress.org/step-by-step-guide-to-setting-up-a-bbpress-forum/ step 6, and every time I make a “forums page” the permalink becomes “forums-2” and I can’t edit it to just “forums”, like there’s already a link with that “forums” even though I don’t have a “forums” page already.
When I delete the forums-related pages, the mydomain.com/forums is still there.
I tried the method 2 from the codex, but I do not like it as the Home > forums is there and when I click on forums, it takes me to a blank page.
How do I fix this permalink issue?
Hello All,
I am using a buddypress+bbpress intergrated site, hence the bbpress profiles are disabled. Only buddypress profiles are made visible because of which I can’t figure out which user is subscribed to which forum. Is there a function or a shortcode using which I can display on the user dashboard the topics/forums he is subscribed to?
Thanks.
Hello All,
I have a buddypress & bbpress integrated site. I am using buddypress groups inside which the bbpress forums exists. There are about 4 groups with 30 members in each group and I have used a “invert subscribe” code (in my functions file), which I came across on one of the threads here. It by default makes the members of the group to be subscribed to the forum and receive email alerts for every thread/topic created.
But now after I installed the Postman email plugin, I noticed that the email notification meant for the members of the group are being sent out to the members of all the group and all the 120+ users on the site. How can I avoid this and see to it that the emails are being sent out only to the particular group members.
Here is the invert subscribe code that I am using:
add_filter( 'bbp_get_user_subscribe_link', 'invert_get_user_subscribe_link', 10, 4 ); //invert forum subscription add_filter( 'bbp_is_user_subscribed_to_forum', 'invert_is_user_subscribed_to_forum', 10, 4 ); //invert forum subscription add_filter( 'bbp_get_forum_subscribers', 'invert_get_forum_subscribers' ); //invert forum subscription add_filter( 'bbp_is_user_subscribed', 'invert_is_user_subscribed', 10, 4 ); //invert forum subscription function invert_is_user_subscribed($retval, $user_id, $object_id, $subscribed_ids) { if (get_post_type( $object_id ) == bbp_get_forum_post_type()) return !$retval; else return $retval; } function strContains($needle, $haystack) { if (strpos($haystack, $needle) !== false) { return true; } else { return false; } } function invert_get_user_subscribe_link ($html, $r, $user_id, $topic_id) { if (strContains( "bbp_unsubscribe", $html )) { $html = str_replace("bbp_unsubscribe", "bbp_subscribe", $html); } else { $html = str_replace("bbp_subscribe", "bbp_unsubscribe", $html); } return $html; } function invert_get_forum_subscribers( $users ) { $args = array('fields' => 'id'); $all_users = get_users($args); $send_to_users = array_diff($all_users, $users); return $send_to_users; } function invert_is_user_subscribed_to_forum( $retval, $user_id, $forum_id, $subscribed_ids ) { return !$retval; } add_action('bbp_theme_after_topic_form_subscriptions', 'subscribed_by_default'); //default subscribe add_action('bbp_theme_after_reply_form_subscription', 'subscribed_by_default'); //default subscribe function subscribed_by_default() { echo '<script type="text/javascript">jQuery("#bbp_topic_subscription").prop("checked","checked");</script>'; } ?>Thanks!
