• Resolved sniemans

    (@sniemans)


    Dear Indigo team,

    First of all, thanks for the great plugin. While implementing we ran into an issue with the generated redirect URL.

    In class-gf-mollie.php, line 240 the URL is generated as follows:

    
    if ( $server_port != '80' ) {
      $pageURL .= $_SERVER['SERVER_NAME'] . ':' . $server_port . $_SERVER['REQUEST_URI'];
    } else {
      $pageURL .= $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
    }
    

    However, on our managed hosting platform (https://pantheon.io/) this format will redirect to their generic ‘app server’ URL rather than our own site. A temporary fix for us was to change the $pageURL value to:

    
    $pageURL .= $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
    

    But of course, we’d rather not change your plugin code.

    Would it be possible to provide an option to override the base return URL in a future version? It would resolve this issue and others like it where the hosting setup breaks this approach.

    Best,
    Stephen

    • This topic was modified 5 years, 6 months ago by sniemans.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Indigo Webstudio

    (@indigonl)

    Hi Stephen,

    We will have a look (this week) and let you know the solution. Looks like an easy adjustment so I expect a small update soon 🙂

    Ciao, Petra

    Plugin Author Indigo Webstudio

    (@indigonl)

    Hi Stephen,

    We think that it is already possible to override redirect url to fit your needs by using the gf_mollie_return_url filter. When you add a filter to your theme’s functions.php like the one below it should be possible to do any modification you desire with the url.

    add_filter( ‘gform_mollie_return_url’, ‘custom_gf_mollie_return_url’, 10, 4 );
    function custom_gf_mollie_return_url( $url, $form_id, $lead_id, $query ) {
    $pageURL = GFCommon::is_ssl() ? ‘https://’ : ‘http://’;
    $pageURL .= $_SERVER[‘HTTP_HOST’] . $_SERVER[‘REQUEST_URI’];

    $ids_query = “ids={$form_id}|{$lead_id}”;
    $ids_query .= ‘&hash=’ . wp_hash( $ids_query );

    $url = add_query_arg( ‘gf_mollie_return’, base64_encode( $ids_query ), $pageURL );

    return $url;
    }

    Please let us know if this solution works for you.

    Thread Starter sniemans

    (@sniemans)

    Hi all,

    Thank you for the swift responses and suggestions thus far. I slightly modified the snippet suggested by Petra/Indigo to the following:

    
    add_filter( 'gform_mollie_return_url', 'set_mollie_return_url', 10, 4 );
    function set_mollie_return_url( $url, $form_id, $lead_id, $query ) {
    	$pageURL   = GFCommon::is_ssl() ? 'https//' : 'http://';
    	$pageURL   .= $_SERVER['HTTP_HOST'] . parse_url( $_SERVER["REQUEST_URI"], PHP_URL_PATH );
    	$ids_query = 'ids=' . $form_id . '|' . $lead_id;
    	$ids_query .= '&hash=' . wp_hash( $ids_query );
    
    	$url = add_query_arg( 'gf_mollie_return', base64_encode( $ids_query ), $pageURL );
    
    	return $url;
    }
    

    In my situation, the user may arrive at the form with some query string parameters that can be used to pre-populate fields. This would cause the return parameters to break (because there would be a missing ‘&’ before it). The solution was to first ‘parse_url’ with ‘PHP_URL_PATH’.

    After that, it was smooth sailing and all my issues seem to have been resolved. Thanks again!

    Plugin Author Indigo Webstudio

    (@indigonl)

    That’s good news Stephen! Thanks for the update 🙂

    Ciao, Petra

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Return URL customization’ is closed to new replies.