Created
May 28, 2018 10:04
-
-
Save svenl77/59a609a698909c42f8d2acda82741417 to your computer and use it in GitHub Desktop.
BuddyForms -> Auto login user after registration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'buddyforms_process_submission_end', 'my_buddyforms_process_submission_end', 10, 1 ); | |
function my_buddyforms_process_submission_end($args){ | |
if( ! isset( $args['user_id'] ) ){ | |
return; | |
} | |
$user_id = $args['user_id']; | |
// Set the current user variables, and give him a cookie. | |
wp_set_current_user( $user_id ); | |
wp_set_auth_cookie( $user_id ); | |
$url = get_home_url(); | |
wp_safe_redirect( $url ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you! This works very well. Richard