Sauter la navigation

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

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

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)

Ce sujet contient 1 réponse, a 2 voix.

Dernière mise à jour par Christian Cox Il y a 5 années et 10 mois.

Assisté par: 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 lien caché

But i need to redirect to lien caché
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>lien caché</u></em>";
    }
  }
  return $url;
}

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