简体   繁体   中英

WP user profile: redirect to new page on update profile submit

I've added a multitude of custom fields to the backend user profile, divided into sections. Each section can be updated using the regular submit button. I have created a checkbox after the last field that when checked, unhides a new Submit button and hides the original submit button. This new submit button is basically an exact copy of the original Submit button in the user-edit.php file except it is placed within its own div.

My question is, how do I modify the code for this new submit button so that it still updates the profile like normal BUT then also redirects the user to a page of my choice? Keep in mind that I don't want the redirect effect to take place at times when the original submit button is clicked as there are numerous custom fields and the user will probably want to periodically update before finishing all the sections.

This is the current code for my new submit button (based on the original submit button in user-edit.php)

<?php submit_button( IS_PROFILE_PAGE ? __('Send My Completed Application') : __('Send My Completed Application') ); ?>

Try this out using the WordPress built in function.

<?php
submit_button( IS_PROFILE_PAGE ? __('Send My Completed Application') : __('Send My Completed Application') );
wp_redirect( 'http://www.example.com', 301 ); exit;
?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM