Skip Navigation

[Résolu] Is it possible to redirect to a custom url after sumitting a form

This support ticket is created Il y a 4 années et 11 mois. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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 1 réponse, has 2 voix.

Last updated by Christian Cox Il y a 4 années et 11 mois.

Assisted by: Christian Cox.

Auteur
Publications
#1230565

I have a form that i would like when it's sumitted to go to a specific url

At the moment it redirect to hidden link

But i need to redirect to hidden link
Which is the same page into wordpress but a different section.

Is there a way or add a function to acheive this?

#1230709

Hi, you can choose a different Page in the Form settings screen, or you can use the Forms API cred_success_redirect to set a different redirect URL with some conditions. For example, let's say there is a custom field in the Form called "page-count" that contains a number. If the page count from the Form is higher than 50, you want to redirect to a different URL. If it's less than 50, you want to redirect to the Page in the Form settings. You would set up that custom code like this:

add_filter('cred_success_redirect', 'custom_redirect_to_custom_url',10,3);
function custom_redirect_to_custom_url($url, $post_id, $form_data)
{
  $forms = array( 12345 );
  if ( in_array( $form_data['id'], $forms ) ) {
    $page_count = get_post_meta( $post_id, 'wpcf-page-count', true );
    if( intval( $page_count ) > 50 ) {
      $url = "<em><u>hidden link</u></em>";
    }
  }
  return $url;
}

More information about this API is available here: https://toolset.com/documentation/programmer-reference/cred-api/#cred_success_redirect

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.