Skip Navigation

[Resolved] Customize Forms redirection message

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to customize the redirection message that is displayed after a Form AJAX submission.

Solution:
You can customize the message by filtering gettext:

add_filter( 'gettext', 'custom_cred_redirection_msg_func', 20, 3 );
 
function custom_cred_redirection_msg_func( $translated_text, $text, $domain ) {
    if($text == 'Please Wait. You are being redirected...' && $domain = 'wp-cred'){
        $translated_text = "<strong>Your message here.</strong>";
    }
    return $translated_text;
}

Relevant Documentation:
http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext

This support ticket is created 6 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 2 replies, has 2 voices.

Last updated by Nicholas 6 years, 5 months ago.

Assisted by: Christian Cox.

Author
Posts
#917145

Thanks, Christian.

Actually, I am using the AJAX form submission feature now with this code

function onElementInserted(containerSelector, elementSelector, callback) {

    var onMutationsObserved = function(mutations) {
        mutations.forEach(function(mutation) {
            if (mutation.addedNodes.length) {
                var elements = $(mutation.addedNodes).find(elementSelector);
                for (var i = 0, len = elements.length; i < len; i++) {
                    callback(elements[i]);
                }
            }
        });
    };

    var target = $(containerSelector)[0];
    var config = { childList: true, subtree: true };
    var MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
    var observer = new MutationObserver(onMutationsObserved);
    observer.observe(target, config);

}

onElementInserted('body', '#lbl_generic', function(element) {
    console.log('error');
    var TopPosition = jQuery('.page-campaign-form, .page-campaign-form-edit').offset().top;
    jQuery('html, body').animate({scrollTop:TopPosition}, 'slow');

However when the post redirects and there's a long loading time it just shows a blank white screen with a small text of ...redirecting...

Would be nice to customize it. I don't want to lose users there if the loading time is too long, which happens sometimes even though I use wpengine.

#917515
Screen Shot 2018-06-25 at 9.58.05 AM.png

Are you talking about this message shown in the attached screenshot?
"Please Wait. You are being redirected..."

This string is localized in the wp-cred domain, so it could be translated using WPML String Translation or another localization tool, or by filtering the gettext function like this:

add_filter( 'gettext', 'custom_cred_redirection_msg_func', 20, 3 );

function custom_cred_redirection_msg_func( $translated_text, $text, $domain ) {
    if($text == 'Please Wait. You are being redirected...' && $domain = 'wp-cred'){
        $translated_text = "<strong>Your message here.</strong>";
    }
    return $translated_text;
}

http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext

#922245

Thanks