Skip Navigation

[Resuelto] Redirect Child Content CRED form back to parent post

This support ticket is created hace 6 años, 10 meses. 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.

Etiquetado: 

This topic contains 6 respuestas, has 2 mensajes.

Last updated by grantD hace 6 años, 10 meses.

Assigned support staff: Minesh.

Autor
Mensajes
#316899

I have a post type with both a parent post type assigned and a child post type that is used to create a many-many relationship with another post type. When editing the primary post type on the front end of the site I want to achieve a single page where both relationships can be defined without needed other pages. So far I'm pretty close.

hidden link (balifood:Development!)

This is what I'm working with so far. The parent relationship was simple to add the cred from directly to the page and have it appear when clicking the change button next to Host. For the many-many relationship, I've put the Cred form for this on a separate page and loaded that page via AJAX under the restaurant's table. The issue is I can't find a way to set up the CRED from to reload the specific fulfillment page when saved. Currently, it reloads to the Add A Restaurant page which isn't helpful.

Is there a way to dynamically set the URL that the CRED form redirects to after submission?

#316930

Minesh
Supporter

Languages: Inglés (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello and thank you for contacting Toolset support.

In general, to redirect to a specific URL after saving the data using CRED form there is a CRED hook available namely "cred_success_redirect".
=> https://toolset.com/documentation/user-guides/cred-api/#csr

add_filter('cred_success_redirect', 'custom_redirect',10,3);
function custom_redirect($url, $post_id, $form_data)
{
	if ($form_data['id']==12)
		return '<em><u>hidden link</u></em>';

	return $url;
}

Hopefully this will help you to set dyanmic URL.

#317052

Thanks for pointing me in the right direction. I've added the following to my themes function.php file but it doesn't appear to be having any effect:

add_filter('cred_success_redirect', 'custom_redirect',10,3);
function custom_redirect($url, $post_id, $form_data)
{
		$Path=$_SERVER['REQUEST_URI'];
		$URI='<em><u>hidden link</u></em>'.$Path;
		if ($form_data['id']==2089){
        return $URI;
		}
    return $url;
}

2089 is the id of my CRED Form in question.

#317153

Minesh
Supporter

Languages: Inglés (English )

Timezone: Asia/Kolkata (GMT+05:30)

*** Please take FULL BACKUP of your database and your website.***
In order to investigate your issue if we require to check things on your install in order to see what could be going wrong there.

If you agree to this please use the form fields I have enabled below this comment box to provide temporary access details (wp-admin and FTP)?

I have set next reply as private.

#317228

Minesh
Supporter

Languages: Inglés (English )

Timezone: Asia/Kolkata (GMT+05:30)

Unfortunately I could not able to login to wp-admin because its asking for for authorization access. Could you please pass me on authorization access details.

#317247

Minesh
Supporter

Languages: Inglés (English )

Timezone: Asia/Kolkata (GMT+05:30)

Sorry for asking authorization access again, I just forget that its available in first post 🙂

Could you please check your issue now, I have modified code in functions.php file little bit as given under:

add_filter('cred_success_redirect', 'custom_redirect',10,3);
function custom_redirect($url, $post_id, $form_data) {
                
		//$Path=$_SERVER['REQUEST_URI'];
		$URI='<em><u>hidden link</u></em>'.$_POST['_wpcf_belongs_fulfillment_id'];
		if ($form_data['id']==2089){
        return $URI;
		}
    return $url;
}

Please check is your issue is resolved and kindly let me know your feedback.

#317263

Awesome, that's working great. Thanks for your assistance.