Skip Navigation

[Resolved] How to redirect user to another section on the same page after registration?

This support ticket is created 5 years, 3 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 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Karachi (GMT+05:00)

This topic contains 4 replies, has 2 voices.

Last updated by StanleyT8485 5 years, 3 months ago.

Assisted by: Waqar.

Author
Posts
#1325733

Tell us what you are trying to do? After the user register, I want to redirect the user to another section on the same page where the registration form is placed.

The section I want to redirect them to is #form.

#1325959

Hi Stanley,

Thank you for waiting, while I performed some tests.

I can confirm that the "cred_success_redirect" hook can be used to attach a custom function that redirects to the same page or its specific section:
( ref: https://toolset.com/documentation/programmer-reference/cred-api/#cred_success_redirect )

Example:


add_filter('cred_success_redirect', 'user_reg_custom_redirect',10,3);
function user_reg_custom_redirect($url, $post_id, $form_data)
{
	if ($form_data['id']==1234) {
		$current_link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
		return $current_link.'/#form';
	}

	return $url;
}

Please replace "1234" with the actual registration form's ID and make sure that the form is set to redirect to any page.
( screenshot: hidden link )

I hope this helps.

regards,
Waqar

#1326615

It didn't work for me.

I get redirected to the page I have set. I have also changed the form ID to the registration form.

Note: I placed the script in the JS editor of the registration form.

#1326679

Hi Stanley,

Thanks for writing back.

Since the code snippet that I shared is a PHP code, it will need to be added at the bottom of the active theme's "functions.php" file.

Please remove it from JS editor section and include it through the theme and then test the form again.

I hope this helps and please let me know how it goes.

regards,
Waqar

#1327775

My issue is resolved now. Thank you!