Skip to content

Instantly share code, notes, and snippets.

@svenl77
Created May 28, 2018 10:04
Show Gist options
  • Save svenl77/59a609a698909c42f8d2acda82741417 to your computer and use it in GitHub Desktop.
Save svenl77/59a609a698909c42f8d2acda82741417 to your computer and use it in GitHub Desktop.
BuddyForms -> Auto login user after registration
<?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 );
}
@boxtreeclinic
Copy link

Thank you! This works very well. Richard

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment