Skip to:
Content
Pages
Categories
Search
Top
Bottom

replies not working sometimes

  • @clivesmith

    Participant

    Hi, I know this is a vague title but,

    Sometimes I create a reply to a topic as a user (I do not have members, anyone can post I moderate all posts) some times it works and i get the thank you return to topic on the screen and it works, other times I press the submit and it just returns to the top of the topic and the post is not submitted and no error message.
    I have checked the debug logs and there is no message in there either. I have tried different computers / phones and browsers. there is obviously a check when it works as it goes to the thank you page, should it go to a bad luck page when the post is not accepted and why would it not be accepted without saying why.
    Any ideas please, I am worried I am losing replies.

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

    Participant

    Any ideas please,

    I cannot find where the thank you page is called.

    @robin-w

    Moderator

    Too 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.

    @clivesmith

    Participant

    Hi Robin,
    Thanks for replyig.
    I copied the same text from notepad into the reply, using firefox, the first time it failed the second time it worked. What I do not to understand is why if it works I get a thank you message but if it fails it just goes to the top of the topic. all the replies are hold for moderaion.
    Is there a way to check that the reply was written to the database then report back to the user.

    @robin-w

    Moderator

    1. 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 versa

    4. and check items 13 and 14 if ticked untick to see if that fixes

    @clivesmith

    Participant

    The thank you message is a page with a permalink of moderation (I last changed it 5 years ago ) the title is Thank you. I cannot find where / how that is called.I think it was introduced because none of the replies are published they all go to moderation.

    On the style pack 16 is ticked if I untick I do not get any thank you message.

    I have tried ticking 17 and adding a message but if there is an error like they leave out the email address it just goes to the top of the topic but no message shows.

    The website is wateratairports.com

    @robin-w

    Moderator

    Suspect that the message is from the moderation settings in style pack, I am about to go to South Africa for 2 weeks so unable to help further until I get back

    @robin-w

    Moderator

    Suspect that the message is from the moderation settings in style pack, I am about to go to South Africa for 2 weeks so unable to help further until I get back

    @clivesmith

    Participant

    Hi Robin
    Thank you, I have now tracked it down to the following code in my functions.php

    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 ($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
    Clive

    @clivesmith

    Participant

    OK 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>';
    }
    
    

    @clivesmith

    Participant

    OK 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>’;
    }

    @clivesmith

    Participant

    what is the FFEPremium tag ?

Viewing 11 replies - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.
Skip to toolbar