Skip Navigation

[Resolved] Conflict between Registration Form redirect and Custom Redirect

This thread is resolved. Here is a description of the problem and solution.

Problem:

The issue here is that the user wanted to redirect to a page after the form is submitted.

Solution:

The correct code example to do this can be seen below.

add_filter('cred_success_redirect', 'custom_room_edit_redirect',10,3);
function custom_room_edit_redirect($url, $post_id, $form_data)
{
if ($form_data['id']==207199){
$url = toolset_get_related_post($post_id, array( 'bb', 'add-room-field' ));
$url = get_permalink($bb_post);
}
return $url ;
}

For more information on this hook take a look at our document here.
https://toolset.com/documentation/programmer-reference/cred-api/#cred_success_redirect

This support ticket is created 5 years, 2 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
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 2 replies, has 2 voices.

Last updated by WayneH4064 5 years, 2 months ago.

Assisted by: Shane.

Author
Posts
#1186805

I am trying to: Redirect to page after registration and auto login. It works fine unless my custom redirect code snippet is activated.

Link to a page where the issue can be seen:
hidden link

I expected to see:
Because I have Auto Login After Registration code installed, the user should be redirected to the My Account page (hidden link)

Instead, I got:
The registration page reloads without redirecting.

Additional info:
I also have a "Code Snippet" with a custom redirect (listed below). When this code is de-activated the registration form properly redirects to the "My Account" page. The custom code ostensibly only redirects upon submit of a child-post edit form to the parent post.

add_filter('cred_success_redirect', 'custom_room_edit_redirect',10,3);
function custom_room_edit_redirect($url, $post_id, $form_data)
{
if ($form_data['id']==207199)
$bb_post = toolset_get_related_post($post_id, array( 'bb', 'add-room-field' ));
$bb_post_url = get_permalink($bb_post);
return $bb_post_url ;
return $url;
}

Thanks in advance for your help sorting this out.
Wayne

#1186837

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Wayne,

Thank you for contacting our support forum.

You code is using multiple lines within the if statement. In this case you will need to wrap the conditional in parenthesis

add_filter('cred_success_redirect', 'custom_room_edit_redirect',10,3);
function custom_room_edit_redirect($url, $post_id, $form_data)
{
if ($form_data['id']==207199){
$url = toolset_get_related_post($post_id, array( 'bb', 'add-room-field' ));
$url = get_permalink($bb_post);
}
return $url ;
}

Also you shouldn't have multiple return statements in a function. Please try this and let me know if this helps.

Thanks,
Shane

#1189049

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.