Search Results for 'code'
-
AuthorSearch Results
-
February 20, 2025 at 2:32 pm #243352
In reply to: Allow Participants to Trash / own Topics and Posts
stableartai
ParticipantSeem this part of code cause the removal of dashboard forum items.
add_filter( ‘bbp_get_caps_for_role’, ‘ST_add_role_caps_filter’, 10, 2 );
February 20, 2025 at 2:21 pm #243351In reply to: Allow Participants to Trash / own Topics and Posts
stableartai
ParticipantThe code seem to work just fine, tried both plug-in and hard code to theme. Issue is when active it remove the dashboard items o manage the forum. Even in plug-ins the settings link is missing from the BBPress plug-in.
We currently use the most recent php 8 and WP 6 as of 2025 and buddypress and bbpress.
Unsure of what else it might break so currently have it disable.
source plug-in:
https://gist.github.com/ntwb/56ab5a4eab8bbcdc90fc2bdfc2c57838February 20, 2025 at 7:38 am #243348Robin W
ModeratorIf you have exported press from another site, and then imported- yes series, and post parents for topics and replies can be wrong where on the imported site there are existing users, posts or pages. There are no easy solutions – I have some code that should fix replies, but I am on holiday at the moment with no access
February 17, 2025 at 7:34 am #243309In reply to: replies not working sometimes
Clivesmith
ParticipantOK There seems to be no fixed reason that the replies are rejected, one minute it works and next it does not. I have 2 pages 1 Thank you page and 1 error page. I am running through cloudflare so I am not sure if that is causing the problem.
This code I have added to the function.php seems to be working// 1 Check if the reply submission has missing fields & redirect to the error page
add_action(‘template_redirect’, ‘rew_check_reply_submission’);function rew_check_reply_submission() {
// Check if a reply is being submitted
if (isset($_POST[‘bbp_reply_submit’])) {
// Check if required fields are missing (e.g., content, forum, topic)
if (empty($_POST[‘bbp_reply_content’]) || !isset($_POST[‘bbp_forum_id’]) || !isset($_POST[‘bbp_topic_id’])) {
// Grab the topic ID from the form (ensure it’s valid)
$topic_id = !empty($_POST[‘bbp_topic_id’]) ? intval($_POST[‘bbp_topic_id’]) : 0;// Redirect to the error page with the topic ID
wp_redirect(site_url(‘/reply_error/?topic_id=’ . $topic_id));
exit; // Stop the script execution after the redirect
}
}
}// 2️ Modify reply redirection: If pending, go to moderation page
add_filter(‘bbp_new_reply_redirect_to’, ‘rew_pending_check’, 30, 3);function rew_pending_check($reply_url, $redirect_to, $reply_id) {
$status = get_post_status($reply_id);
$topic_id = bbp_get_reply_topic_id($reply_id);// If the reply is pending moderation, redirect to the moderation page
if ($status === ‘pending’) {
return site_url(‘/moderation/?moderation_pending=’ . $topic_id);
}return $reply_url; // Otherwise, return the usual redirect URL
}// 3 Create a shortcode [mod-return] to display “Return to Topic” on error and moderation pages
add_shortcode(‘mod-return’, ‘mod_return’);function mod_return() {
// Get the topic ID from the URL (works for both error and moderation pages)
$topic_id = !empty($_GET[‘topic_id’]) ? intval($_GET[‘topic_id’]) : (!empty($_GET[‘moderation_pending’]) ? intval($_GET[‘moderation_pending’]) : 0);// If a valid topic ID is found, generate the “Return to Topic” button
if ($topic_id) {
$topic_url = get_permalink($topic_id);if ($topic_url) {
return ‘<div class=”mod-return” style=”text-align:center; margin-top:20px;”>
<a href=”‘ . esc_url($topic_url) . ‘”
style=”color:white; background-color:tomato; padding:12px 20px;
border-radius:5px; text-decoration:none; font-size:16px;”>
⬅ Return to Topic</div>’;
}
}// If no valid topic ID found, return nothing or a message
return ‘<p style=”text-align:center; color:red;”>No topic found to return to.</p>’;
}February 17, 2025 at 7:29 am #243308In reply to: replies not working sometimes
Clivesmith
ParticipantOK so just to let you know this is what I have and it seems to be working, There does not seem to be any fixed reason that the replies get rejected without warning. I am running cloudflare so I cannot rule that out.
I have two pages, a thank you page and an error page, this code is in my function.php which seems to be working.// 1 Check if the reply submission has missing fields & redirect to the error page add_action('template_redirect', 'rew_check_reply_submission'); function rew_check_reply_submission() { // Check if a reply is being submitted if (isset($_POST['bbp_reply_submit'])) { // Check if required fields are missing (e.g., content, forum, topic) if (empty($_POST['bbp_reply_content']) || !isset($_POST['bbp_forum_id']) || !isset($_POST['bbp_topic_id'])) { // Grab the topic ID from the form (ensure it's valid) $topic_id = !empty($_POST['bbp_topic_id']) ? intval($_POST['bbp_topic_id']) : 0; // Redirect to the error page with the topic ID wp_redirect(site_url('/reply_error/?topic_id=' . $topic_id)); exit; // Stop the script execution after the redirect } } } // 2️ Modify reply redirection: If pending, go to moderation page add_filter('bbp_new_reply_redirect_to', 'rew_pending_check', 30, 3); function rew_pending_check($reply_url, $redirect_to, $reply_id) { $status = get_post_status($reply_id); $topic_id = bbp_get_reply_topic_id($reply_id); // If the reply is pending moderation, redirect to the moderation page if ($status === 'pending') { return site_url('/moderation/?moderation_pending=' . $topic_id); } return $reply_url; // Otherwise, return the usual redirect URL } // 3 Create a shortcode [mod-return] to display "Return to Topic" on error and moderation pages add_shortcode('mod-return', 'mod_return'); function mod_return() { // Get the topic ID from the URL (works for both error and moderation pages) $topic_id = !empty($_GET['topic_id']) ? intval($_GET['topic_id']) : (!empty($_GET['moderation_pending']) ? intval($_GET['moderation_pending']) : 0); // If a valid topic ID is found, generate the "Return to Topic" button if ($topic_id) { $topic_url = get_permalink($topic_id); if ($topic_url) { return '<div class="mod-return" style="text-align:center; margin-top:20px;"> <a href="' . esc_url($topic_url) . '" style="color:white; background-color:tomato; padding:12px 20px; border-radius:5px; text-decoration:none; font-size:16px;"> ⬅ Return to Topic </a> </div>'; } } // If no valid topic ID found, return nothing or a message return '<p style="text-align:center; color:red;">No topic found to return to.</p>'; }
February 14, 2025 at 12:04 pm #243278In reply to: replies not working sometimes
Clivesmith
ParticipantHi Robin
Thank you, I have now tracked it down to the following code in my functions.phpadd_filter (‘bbp_new_reply_redirect_to’ , ‘rew_pending_check’, 30 , 3) ;
function rew_pending_check ($reply_url, $redirect_to, $reply_id) {
$status = get_post_status ($reply_id) ;
$topic_id = bbp_get_reply_topic_id( $reply_id );
if ($status == ‘pending’ ) {
$reply_url = ‘/moderation/?moderation_pending=’.$topic_id ;
}
return $reply_url ;
}add_shortcode (‘mod-return’ , ‘mod_return’ ) ;
function mod_return () {
if (!empty($_REQUEST[‘moderation_pending’] )) {
$topic_url = get_permalink( $_REQUEST[‘moderation_pending’] );
echo ‘<div class=”mod-return”><h2 style=”color:Tomato;”>Return to topic</h2></div>’;
}
}just got to work out how to bring up a different page if the post is not saved, dont warry go and have a nice holiday you deserve it.
I will post the answer when I work it out.Regards
CliveFebruary 14, 2025 at 9:35 am #243274In reply to: replies not working sometimes
Robin W
Moderator1. not sure what is the ‘thankyou message’ you get?
A reply I make just gets accepted and then goes to the reply with the url which is the ID of the reply.
/forums/topics/testtopic/#post-33905
so what is adding the ‘thankyou’ message
2. If it is written to the database it will be in
dashboard>settings>replies either in all, pending, trash or spam – if it is not there, then it is not in the database.
3. what have you got set in
dashboard>settings>bbp style pack>Topic/Reply Form item 16 if checked, try unchecking it or visa versa4. and check items 13 and 14 if ticked untick to see if that fixes
February 14, 2025 at 8:45 am #243272In reply to: replies not working sometimes
Robin W
ModeratorToo many variables to be able to help in any generic way.
You will need to try and work out what makes some work and some not.
So each time before you post, take a copy of the reply content , note the date and time, and keep doing this for both successful and failed replies. Note also any other people posting around the time that you did.
When you have got say 20 failed replies, you can start to analyze whether there is any common reason, such as words, length, no. paras, subject matter, time of day etc.
If that fails, then you could start to think that it is not code related, so maybe hosting platform, eg memory – say 3 people using the site at once.
February 13, 2025 at 10:51 pm #243251In reply to: Has anyone used the bbpress ajax replies plugin??
issobruno
Participantafter hours I get this code that works so fine!!
function bbpress_comentarios_ajax() { ?> <script type="text/javascript"> jQuery(document).ready(function($) { $('#bbp_reply_submit').click(function(e) { e.preventDefault(); // Impede o recarregamento normal var form = $(this).closest('form'); var formData = form.serialize(); $.post(form.attr('action'), formData, function(response) { // Recarrega só a área dos comentários $('.bbp-replies').load(window.location.href + ' .bbp-replies > *'); form[0].reset(); // Limpa o campo de resposta }); }); }); </script> <?php } add_action('wp_footer', 'bbpress_comentarios_ajax');
enjoy 🙂
February 13, 2025 at 11:40 am #243246In reply to: When Support Block Theme?
WebMan Design | Oliver Juhas
Participant@robin-w, FYI, the main code which provides the compatibility can be found in
includes/Compatibility.php
file.February 13, 2025 at 11:36 am #243245In reply to: When Support Block Theme?
WebMan Design | Oliver Juhas
ParticipantHi @robin-w,
Feel free to study the code at https://github.com/webmandesign/bbp-block-theme
Thank you for your fix via your bbp style pack plugin. As far as I understand, your plugin also provides means to style bbPress plugin. In my plugin this is not an option – it really just enables bbPress for block themes.
For how the plugin actually works check the info in
readme.txt
file.February 13, 2025 at 11:22 am #243244In reply to: When Support Block Theme?
Robin W
ModeratorInteresting – my style pack plugin has a fix for block themes, but from very little knowledge of FSE. I’m away for the next few weeks, but will be interesting to take a look at the code you have done.
February 12, 2025 at 12:53 pm #243225In reply to: PHP notice on version 2.6.11
Robin W
Moderatorpretty sure that it is LearnPress – bbPress Integration
We have submitted a change required to Learndash.
If you are into code the fix is in learndash-bbpress\includes\class-dependency-check.php line 119 – the line needs changing from
$plugin_header = get_plugin_data( trailingslashit( str_replace( '\\', '/', WP_PLUGIN_DIR ) ) . $plugin_key );
to$plugin_header = get_plugin_data( trailingslashit( str_replace( '\\', '/', WP_PLUGIN_DIR ) ) . $plugin_key, false, false );
This then prevents translations being loaded at that point (too early) and hopefully fixes the issue.
February 9, 2025 at 12:03 am #243142In reply to: Disable “pending” status to allow all content.
painlessseo
ParticipantHi @akira010203, I’m fairly new to bbpress and I don’t understand why we need to use Settings -> Discussion -> Comment Moderation to allow links in bbpress Replies.
Isn’t that setting for Comments?
I have some users/participants whose replies will go straight to pending if they post ONE link despite that I set ‘Hold a comment in the queue if it contains 2 or more links’.
How does the anti spam code logic work in bbpress? I’m quite confused.
Your input will be greatly appreciated!
February 8, 2025 at 4:39 am #243133In reply to: Subscribe Existing Users to New Forum
Robin W
Moderatorusers can subscribe to forums and topics, both work the same way. The post ID is either a forum or topic.
Not suer what you mean by command – if sql then I cannot help you. If php then you would use get_users and loop through that and use
bbp_add_user_subscription( $user_id, $forum_id )
private groups – the code simply checks matches. Users have a user_meta entry of ‘private_group’ and forums have a post_meta of ‘_private_group’ the general settings are stored in the options table
February 6, 2025 at 2:29 pm #243113Robin W
ModeratorThe following hooks are the nearest to what you want
do_action( 'bbp_template_before_replies_loop' ); ?> do_action( 'bbp_template_before_forums_loop' ); ?> do_action( 'bbp_template_before_topics_loop' ); ?>
February 6, 2025 at 10:06 am #243111In reply to: Subscribe Existing Users to New Forum
Robin W
Moderatorforum subscribed users are held in post_meta database for the forum
so if the forum is ID 2927, then in post_meta you would have an entry for each subscribed user eg
`
post_id meta_key Meta_value 2927 _bbp_subscription 1371 2927 _bbp_subscription 1372
would mean that user_ID’s 1371 and 1372 are subscribed to forum 2927
February 5, 2025 at 1:22 am #243079In reply to: last active time updates for spam comments
manojmohandev
ParticipantLooks like it was fixed way back when codebase was not modularized to this extent. Here is the ticket that was closed some 13 years back with commit that fixes it.
If you observe these check doesn’t exist anymore before updating last reply id and all.
// Update if reply is published if ( bbp_is_reply_published( $reply_id ) ) update_post_meta( $topic_id, '_bbp_last_reply_id', (int) $reply_id );
February 4, 2025 at 10:01 pm #243076In reply to: Private messages
takeshihikari1
BlockedHere are a few options:
bbPress Messages: This plugin offers a simple yet powerful private messaging system tailored specifically for bbPress. It includes features like message caching for faster performance, background processing for tasks such as email notifications, and support for shortcodes and widgets.
JA.WORDPRESS.ORGBetter Messages: A comprehensive real-time private messaging system compatible with bbPress, BuddyPress, and other WordPress platforms. It provides features like live chat, file uploads, emoji support, message editing and deleting, and even audio and video calls.
JA.WORDPRESS.ORGbbPress – Private Replies: This plugin allows forum participants to mark their replies as private, meaning only the original poster and forum moderators can view the content. It’s particularly useful for support forums where users may need to share confidential information.
February 4, 2025 at 5:23 pm #243074Topic: Topic archive pagination broken
in forum Installationswinggraphics
ParticipantOn the Topics archive page, the pagination links are broken, going to a forum. This appears to be due to
maybe_map_permalink_to_group()
. My solution is to add a filter afterBBP_Forums_Group_Extension->topic_pagination()
to correct thebase
parameter:/* Fix BBPress pagination */ function my_topic_pagination_fix( $r ) { if ( is_post_type_archive( 'topic' ) ) { $r['base'] = bbp_get_topics_pagination_base(); } return $r; } add_filter( 'bbp_topic_pagination', 'my_topic_pagination_fix', 11 );
February 4, 2025 at 11:09 am #243072In reply to: last active time updates for spam comments
Robin W
Moderatorthe code above provides a fix.
without knowing what your code does, impossible to provide a hook
February 4, 2025 at 8:25 am #243069In reply to: last active time updates for spam comments
manojmohandev
ParticipantEven I am facing this issue. Ideally they should not update reply count or any other metrics if the reply or topic is form. I have found a way to tweak the codebase and do it but I want the plugin developer to provide some hook for it.
February 1, 2025 at 2:16 pm #243024Topic: PHP notice on version 2.6.11
in forum Requests & Feedbackmarbaque
ParticipantI am receiving this php notice:
Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the bbpress domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later.
I am running Version 2.6.11
January 25, 2025 at 5:29 am #242917Topic: BBPress doesn’t work with Blog FSE theme
in forum ThemesJoakim Nömell
ParticipantHello. I run a site where I use the theme Blog FSE. BBPress does not work with this theme. It works fine with Twentysixteen, for example. Is there any way to solve this so that BBPress can work with Blog FSE so I don’t have to change themes? My knowledge of PHP is low and I have a visual impairment and therefore it is quite difficult to work too much in PHP code.
Latest WordPress and BBPress versions.
January 21, 2025 at 2:39 pm #242849In reply to: This forum is empty
Robin W
ModeratorTo do this without code install
once activated go to
dashboard>settings>bbp style pack>Forums Index Styling item 16
or with the code above use
-
AuthorSearch Results