• Resolved winnewoerp

    (@joschi81)


    Hi there,

    I don’t know exactly if this is a coding issue or another problem with my blog settings in general: After a comment validation error page, the content disappears after clicking the back button (the form is empty). Also, the respective .php page is reloading completely (instead of retrieving it from the cache in another blog I have, where it works correctly).

    Here’s a bit of code:

    add_filter( 'preprocess_comment', 'verify_comment_meta_data' );
    function verify_comment_meta_data( $commentdata ) {
    if ($_POST['comment_code'] != $_SESSION['rand_code'])
    	wp_die( __( 'Fehlermeldung: Sie haben nicht den richtigen Spamschutz-Code eingegeben.' ) );
    	return $commentdata;
    }

    As I said, the problem might be outside this snippet…

    Thanks
    Josch

Viewing 15 replies - 1 through 15 (of 17 total)
  • if it is running wp_die, then it’s ending there, so it’s never returning anything

    Thread Starter winnewoerp

    (@joschi81)

    Thanks. Any proposal for a working solution? The code I pasted is for the captcha validation – but for the “default” wp_die() page (for missing name, e-mail…) it’s also not working.

    I don’t know that there’s any way once the comment form has been submitted to test against the captcha and make the function stop, however, you could use ajax to test the captcha before submitting the comment form to test if the captcha is right, if it is, then submit the form, if it isn’t return an error (or make an error div visible) and change the captcha

    Thread Starter winnewoerp

    (@joschi81)

    Ajax would be a solution for the captcha field, but as it’s not working for the other comment fields as well, it seems that there is another problem. Could it be a caching problem or something like that?

    And apart from that: is there an (easy) way to replace the WP error page on comments by an error message within the comment form (php, without using ajax!)?

    Josch

    I stand corrected, looking through some search results, it is possible, but if all you are trying to do is add captcha to a comment form, my recommendation would be to get a plugin already designed to do so..

    http://wordpressapi.com/2010/08/04/wordpress-comments-captcha-plugin/

    there’s a url with a list of plugins to do what you want 🙂

    Thread Starter winnewoerp

    (@joschi81)

    Thx again 😉 I already had SI CAPTCHA installed and activated it for testing. Same problem: comment data disappears after hitting back button. I agree with what you said, after wp_die() the $_POST data isn’t available anymore. But then why does it work in my other blog? I have SI CAPTCHA there as well.

    Strange thing.

    Josch

    same host/server? could be the way the server is configured, or something similar.. can’t really answer that..

    Thread Starter winnewoerp

    (@joschi81)

    Same host, but maybe not the same server (don’t know). But I guess that they don’t have different configurations.

    The problem is that every page is completely re-loaded in the new blog. In the old one (where it works like a charm), every previous page is (or seems to be) loaded from the cache. But this isn’t a WP then…

    But isn’t there a simple way to change error validation of comments, so that the form is reloaded with the fields filled as before and an error message appears?

    are you using a cache plugin on one and not on the other? or have one of the caching options set differently?

    Thread Starter winnewoerp

    (@joschi81)

    SI CAPTCHA Anti Spam and Post From Site are the only two plugins that are running on the old system. Can’t figure out if one of those has influence on caching.

    What caching options are there? I can’t find anything in the www, except a bunch of plugins that can be used for optimize caching of WP sites.

    not sure, i’ve seen some themes that have caching options built in, but mostly it’s plugins, or if there’s a caching feature compiled into php or apache (not sure about apache)

    Thread Starter winnewoerp

    (@joschi81)

    I installed W3 Total Cache today, but this didn’t have any effect.

    So if anyone knows the solution for this (restore comment content after wp_die() page), please let me know.

    Thx
    Josch

    Thread Starter winnewoerp

    (@joschi81)

    I can’t figure out how to get this working. And I don’t find any good solution wiht google search. I don’t understand why. Aren’t there many other people have the same problem with the user unfriendly comment validation of WP?

    Any workaround?

    Moderator bcworkz

    (@bcworkz)

    I don’t have your problem, so I can’t really investigate. I don’t see any traffic generated when I use my back button from a wp_die() error page. So what ever it is, it might be in the way the comment form is served in the first place. Different themes maybe?

    This comment probably doesn’t help you, but I figured you never know when one idea, even bad ones, will set you on a path to discovery.

    Thread Starter winnewoerp

    (@joschi81)

    Thanks bcworkz. I think it helped me, because after reading your comment I came to the idea that maybe my plugin is causing the problem. And, yeah, it does!

    This line is located in the beginning of the plugin:

    if ( !session_id() ) add_action( 'init', 'session_start' );

    My problem is: I don’t have any idea right now how I can prevent a new session from being started when I return from the wp_die() page.

    Any idea anyone?

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘Comment validation: Data disappears after clicking "back" button’ is closed to new replies.