• Resolved juslintek

    (@juslintek)


    I’ve created my custom

    wp-content/wp-maintenance-mode.php

    template, which I saw is supported in

    init()

    function, because in code it looks for this file over at wp-content. SO I added

    wp_head();

    before end of </head>
    and before end of </body> added

    _wp_footer_scripts();

    to load all necessary js for CF7. After lots of reading, debugging var_dumping, hard-coding I found a hardcode fix. But I would appreciate a long term solution. Because my fix could be removed any update if not looked into, or it should be added to

    wp-content/plugins/wp-maintenance-mode/includes/classes/wp-maintenance-mode.php

    . So here is the fix:

    Find init() function on last mentioned file. In my case line: 419.

    At the end or beginning, up to your preferences, of if statement add this validation rule:
    && !intval($_POST[‘_wpcf7_is_ajax_call’]), it can be as well !isset, or !empty, but I found that $_POST[‘_wpcf7_is_ajax_call’] value is always 1, so probably it is like that for a reason, so I left intval validation. As conclusion: this should prevents from loading 503 header and returning

    maintenance.php or wp-content/wp-maintenance-mode.php html.

    P.S. After changes if statement in init() function should look something like that:
    ……

    public function init() {
                /**
                 * CHECKS
                 */
                if (
                        (!$this->check_user_role()) &&
                        !strstr($_SERVER['PHP_SELF'], 'wp-cron.php') &&
                        !strstr($_SERVER['PHP_SELF'], 'wp-login.php') &&
                        !strstr($_SERVER['PHP_SELF'], 'wp-admin/') &&
                        !strstr($_SERVER['PHP_SELF'], 'async-upload.php') &&
                        !(strstr($_SERVER['PHP_SELF'], 'upgrade.php') && $this->check_user_role()) &&
                        !strstr($_SERVER['PHP_SELF'], '/plugins/') &&
                        !strstr($_SERVER['PHP_SELF'], '/xmlrpc.php') &&
                        !$this->check_exclude() &&
                        !$this->check_search_bots() &&
                        !intval($_POST['_wpcf7_is_ajax_call'])
                ) {
                    // HEADER STUFF

    ……

    https://wordpress.org/plugins/wp-maintenance-mode/

Viewing 1 replies (of 1 total)
  • Thanks for this suggestion.
    I had the same need to include a custom CF7 form inside the wp-maintenance/views/maintenance.php template and your fix helped me a lot.

    The reason why I’ve done that was that with the standard contact form, on Firefox, users don’t get the feedback of “Mail sent to webmaster” and keep clicking on “Send” again, so we get many copies of the same email.

    Would kindly ask the plugin developer to take into consideration this in one of the next releases.

Viewing 1 replies (of 1 total)
  • The topic ‘Contact Form 7 503 ajax response in maintenance mode (hardcode fix included)’ is closed to new replies.