Home › Toolset Professional Support › [Resolved] Success message on redirect page after form submission
Problem: I would like to redirect to the homepage after submitting a Form, and I would like to display a success message there.
Solution: You could append a special URL parameter to the redirection URL, then use conditional HTML on your homepage template to display a notice. To append a URL parameter to the redirection URL, you must set up the Form to redirect to some page. It doesn't matter which page, we will override that in code.
function tssupp_delete_user_redirect( $url, $post_id, $form_data ){ if ( 123 == $form_data['id'] ) { $url = 'https://yoursite.com/?user-deleted=1'; } return $url; } add_action( 'cred_success_redirect', 'tssupp_delete_user_redirect', 10, 3 );
Replace 123 with the numeric ID of the delete User Form.
Your visitor will be redirected to the homepage with the URL parameter added. Then in your homepage template you can display the message using conditional HTML:
[wpv-conditional if="( '[wpv-search-term param="user-deleted"]' eq '1' )"] Your account has been deleted. [/wpv-conditional]
Relevant Documentation:
https://toolset.com/documentation/programmer-reference/cred-api/
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.
This topic is split from https://toolset.com/forums/forum/professional-support/
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
Tagged: Toolset Forms, User-registration forms
Related documentation:
This topic contains 2 replies, has 2 voices.
Last updated by diyanK 5 years, 9 months ago.
Assisted by: Christian Cox.
Hi team,
I'm trying to create fully functional delete (self) account feature on my project and I need a little help.
I started with the guide from this ticket:
https://toolset.com/forums/topic/add-the-link-delete-account/#post-1223439
The method works and deletes the custom user and his custom posts. Also how about a working confirmation msg that shows on the homepage once the user gets redirected back to it after deletion?
Thanks in advance!
Diyan
You could append a special URL parameter to the redirection URL, then use conditional HTML on your homepage template to display a notice. To append a URL parameter to the redirection URL, you must set up the Form to redirect to some page. It doesn't matter which page, we will override that in code.
function tssupp_delete_user_redirect( $url, $post_id, $form_data ){ if ( 123 == $form_data['id'] ) { $url = '<em><u>hidden link</u></em>'; } return $url; } add_action( 'cred_success_redirect', 'tssupp_delete_user_redirect', 10, 3 );
Replace 123 with the numeric ID of the delete User Form.
Your visitor will be redirected to the homepage with the URL parameter added. Then in your homepage template you can display the message using conditional HTML:
[wpv-conditional if="( '[wpv-search-term param="user-deleted"]' eq '1' )"] Your account has been deleted. [/wpv-conditional]
Worked like a charm!
I didn't know we can use conditionals this way, this is a very nice feature with a great potential for use in my projects.
Also I wrapped the alert in these:
<div class="alert alert-danger alert-dismissible" role="alert">Your account has been deleted.</div>