• Resolved jamminjames

    (@jamminjames)


    We’d like to save a url as a custom value in a hidden field to pass on as a query parameter. The url we want to save contains query parameters itself, including an ampersand. The ampersand is getting translated into “&amp%3B”. We tried using the “%26″ encoding shown here for special characters, but that disappears completely. We’ve also tried “&” and “&” as shown here, and even an escape backslash. Nothing works.

    How can we insert an ampersand into a custom value string for a hidden field?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Support Kris – WPMU DEV Support

    (@wpmudevsupport13)

    Hi @jamminjames

    I hope you are doing well today.

    I pinged our SLS Team to review your query what will be possible in this case. We will post an update here as soon as more information is available.

    Kind Regards,
    Kris

    Plugin Support Kris – WPMU DEV Support

    (@wpmudevsupport13)

    Hi again @jamminjames

    add_filter( 'forminator_form_submit_response', 'wpmudev_fix_response_url_redirect', 20, 2 );
    add_filter( 'forminator_form_ajax_submit_response', 'wpmudev_fix_response_url_redirect', 20, 2 );
    function wpmudev_fix_response_url_redirect( $response, $form_id ) {
    	if ( $form_id != 6 ) {
    		return $response;
    	}
    
    	if ( ! empty( $response['url'] ) ) {
            $response['url'] = urldecode($response['url']);
            $response['url'] = str_replace('&', '&', $response['url']);
    	}
    
    	return $response;
    }

    You need to change 6 to your form ID. You can find your form ID in page source where form is located, or edit your form in WP Dashboard and URL of that page edit will contain that ID.

    Kind Regards,
    Kris

    Thread Starter jamminjames

    (@jamminjames)

    Wouldn’t this work in a child theme’s functions.php file as well?

    Plugin Support Amin – WPMU DEV Support

    (@wpmudev-support2)

    Hello @jamminjames ,

    Yes, it should work, but it’s better to use MU plugin.

    kind regards,
    Kasia

    Thread Starter jamminjames

    (@jamminjames)

    Just curious, why is that considered to be better?

    Plugin Support Williams – WPMU DEV Support

    (@wpmudev-support8)

    Hi @jamminjames

    MU (Must Use) plugins are separate (or “independent”) from themes. A code added as MU plugin will not be overwritten/removed upon theme update and will remain there active and working even if you switch theme (for good or just temporarily for testing) to some other one.

    It also is easier to maintain and troubleshoot in future as it’s clear that the code is actually not a part of the theme and it’s often simply easier to find and identify such code.

    MU plugins are also loaded by PHP before all other plugins are loaded which, in many cases, may actually be useful and helpful (e.g. if “priority matters” for the executed code).

    But, as my colleague already mentioned, this particular code should also work fine if added to “functions.php” so if you prefer to use it like that – there’s nothing in a way ??

    Best regards,
    Adam

    Thread Starter jamminjames

    (@jamminjames)

    Okay, thanks! We’re using it in functions.php and it’s working fine.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Save text with special character in hidden field’ is closed to new replies.