• Resolved gavin310

    (@gavin310)


    I have a two-step process. The step 1 form has a success message with a URL to step 2 that includes the email address field:

    <a >Complete your profile</a>

    In the step 2 form there’s a hidden field that gets the query string variable using {querystring:email}. The problem is that the email address is not encoded, so if there’s a + in the email (for example “[email protected]” which is a valid email) it’s being converted to a space in the hidden field’s value, so it’s populated as “myname [email protected]”.

    Is there another way to include a field’s value in a URL so that it’s encoded?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter gavin310

    (@gavin310)

    I also emailed Ninja Forms support about this and they blamed it on PHP, so I went into the source and found a filter where I can modify the success message. This filter will find all email addresses in the success message and replace + with %2B.

    add_filter( 'ninja_forms_run_action_settings', function( $action, $form_id, $action_id ) {

    if ( isset( $action['type'] ) && 'successmessage' === $action['type'] ) {

    preg_match( '/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}/i', $action['success_msg'], $matches );

    if ( $matches ) {

    foreach ( $matches as $match ) {

    $email_encoded = str_replace( '+', '%2B', $match );

    $action['success_msg'] = str_replace( $match, $email_encoded, $action['success_msg'] );

    }

    }

    }

    return $action;

    }, 10, 3 );
    Thread Starter gavin310

    (@gavin310)

    I should add that my filter works in my case because the only email address is the one that gets passed into the query string of a link. If you have any email addresses in the success message that aren’t in a query string or href then this filter shouldn’t be used because it’ll display those emails with %2B in them.

    Plugin Support xmiax

    (@xmiax)

    Hi. 

    Thanks for reaching out.? I’m Mia and I work for Ninja Forms.? As we outline in?this post, we prefer supporting our users on?NinjaForms.com?so we can better track issues.? I can give you a quick answer to this question, but if more details are needed I’ll have to refer you to our normal support system.?

    I asked the engineering team to make sure I was giving you the correct information.? This is a limitation of the PHP url_encode() function.? The querystring is a URL and URL encoding converts characters into a format that can be used in a browser. URLs can’t have the + sign in them so the + sign is interpreted as a space.??It’s not something we can work around at this time.

    You can use the code supplied by the other user if you like. However, we can’t offer support for custom code.

    Thanks for choosing Ninja Forms for your website.   

    Mia

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