Skip Navigation

[Resolved] Edit Form REDIRECT With A URL Parameter

This support ticket is created 5 years, 6 months ago. 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+01:00)

Tagged: 

This topic contains 4 replies, has 2 voices.

Last updated by Bobby339 5 years, 6 months ago.

Assisted by: Nigel.

Author
Posts
#1120699

Hello Toolset Support!

How can I add a URL parameter to the REDIRECT of an Edit Post form?

The "Go to a page..." option for the "What to show after submitting the form:" feature only lets me select a page from a dropdown list... but what I would like to do is just have the ability to include the post ID (that has just been edited) in the REDIRECT URL.

After making an edit to the post, a redirect with something like hidden link and on that 'thank you' page I will place a View that looks for a URL variable so I can display something like "Thank you for editing the [TITLE GOES HERE] post".

I would have other variables on that thank you page, but the redirect URL param is what I am missing.

Thank you.

#1120798

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Hi Ian

You can modify the redirect URL using the cred_success_redirect hook: https://toolset.com/documentation/programmer-reference/cred-api/#cred_success_redirect

This little snippet would add a parameter 'edited' with the post id:

<?php
/**
 * Customise redirect URL
 */
function tssupp_custom_redirect( $url, $post_id, $form_data ){

	if ( $form_data['id'] == '31' ) { // Edit form id

		$url .= '?edited=' . $post_id;

	} 

	return $url;
}
add_filter( 'cred_success_redirect', 'tssupp_custom_redirect', 10, 3 );

You can read about the new feature to add Code Snippets in Types 3.1 here: https://toolset.com/documentation/adding-custom-code/

#1120813

Thank you for that new Code Snippet feature! Works well!

I implemented your code (and changed the form ID) and the Post Form now redirects to the correct page BUT with the wrong URL parameter. This is currently the url when the form redirects:

hidden link

That 773 at the end is the POST FORM id... I need the POST ID that was just edited (not the form)... and how can I change "cred_referrer_form_id" to something like "productid"?

#1120824

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

It should have added a parameter 'edited', it's the 9th line in the above snippet.

On my test site it added ?edited=123&cred_referrer_form_id=321, so if you are not seeing the edited parameter added it suggests either the code isn't running at all or the form ID is wrong...

#1121038

MY FAULT: I needed to "Activate" the custom code... simply "Saving" does not "Activate" the code (and that's why it looked like the code didn't work properly). My issue is resolved now. Thank you!

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