Skip Navigation

[Résolu] Redirect to parent after child edit.

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem:
How to Redirect to parent post after editing/creating child post using Toolset Form

Solution:
You can use the Toolset Forms hook "cred_success_redirect" in order to add customized redirection.

You can find the proposed solution in this case with the following reply:
https://toolset.com/forums/topic/redirect-to-parent-after-child-edit/#post-1503495

Relevant Documentation:
=> https://toolset.com/documentation/programmer-reference/cred-api/#cred_success_redirect
=> https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/

This support ticket is created Il y a 4 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

Ce sujet contient 5 réponses, a 2 voix.

Dernière mise à jour par Mike Il y a 4 années et 10 mois.

Assisté par: Minesh.

Auteur
Publications
#1502941

Tell us what you are trying to do?

I have a parent post called States, in this post I have a view that lists child posts called People. In that view I have a content template that I want to add a link to that will allow me to click and edit the chile post. When I submit the edit I want to return to the parent, not the child. So I can then go to the next person.

Is there any documentation that you are following?

I have seen this but I do not know how to use it. https://toolset.com/documentation/programmer-reference/cred-api/#cred_success_redirect

#1503227

Minesh
Supporter

Les langues: Anglais (English )

Fuseau horaire: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

The hook you shared is correct. You need to use that cred_success_redirect hook for redirection.

Can you please tell me what is your parent post URL - where you added the child form?

#1503363

The URL is: lien caché

But /california will be different for every state.

#1503393

Minesh
Supporter

Les langues: Anglais (English )

Fuseau horaire: Asia/Kolkata (GMT+05:30)

Sorry - I do not understand, do you mean that California value will be different for every child page?

Can you please share the problem URL where you list all parent entries and access details so I can check your current setup and accordingly guide you in the right direction.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#1503495

Minesh
Supporter

Les langues: Anglais (English )

Fuseau horaire: Asia/Kolkata (GMT+05:30)

Can you please check now: lien caché

I've added the following code to the "Custom Code" section offered by Toolset:
=> lien caché

add_filter('cred_success_redirect', 'func_custom_redirect',10,3);
function func_custom_redirect($url, $post_id, $form_data){
  
    if ($form_data['id']==130){
      	 
         $parent = get_post_field( 'post_name', $_POST['@state-person_parent']);
          $url = "<em><u>lien caché</u></em>".$_SERVER['HTTP_HOST'].'/state/'.$parent;
         return $url;
    }
   
    return $url;
}

More info:
=> https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/

I can see its redirecting back to the correct parent state page.

#1503507

Thank you very much and looking at the code snippet I see how you did that now. My issue is resolved. Thanks again!