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.
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
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.
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
My issue is resolved now. Thank you!