mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-04-29 11:32:21 +08:00
https://docs.ultimatemember.com/article/1756-redirect-to-previous-page-after-registration
18 lines
699 B
Text
18 lines
699 B
Text
add_action( 'um_registration_complete', 'um_072522_redirect_to_previous_after_register', 10, 2 );
|
|
function um_072522_redirect_to_previous_after_register( $user_id, $args ){
|
|
|
|
if( 5 == $args['form_id'] ){
|
|
$previous_page_url = $_COOKIE['um_previous_page'];
|
|
if( ! empty( $previous_page_url ) ){
|
|
setcookie('um_previous_page', null, strtotime('-1 day'));
|
|
wp_redirect( $previous_page_url ); exit;
|
|
}
|
|
}
|
|
}
|
|
|
|
add_action('init', function() {
|
|
if ( ! um_is_core_page("register") && ! is_user_logged_in() ) {
|
|
$current_url = UM()->permalinks()->get_current_url();
|
|
setcookie('um_previous_page', $current_url, strtotime('+1 day'));
|
|
}
|
|
});
|