Skip to content

Instantly share code, notes, and snippets.

@WordBits
Created September 24, 2018 16:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WordBits/6c575be6441f7d6057b26e5a94ec24c6 to your computer and use it in GitHub Desktop.
Save WordBits/6c575be6441f7d6057b26e5a94ec24c6 to your computer and use it in GitHub Desktop.
Auto login after register user in wordpress and redirect to a home page.
<?php
// Download this snippet as a plugin and more at: https://wordbits.io/snippet/auto-login-after-registration/
// Created by: Ravi Patel
?>
<?php
function auto_login_new_user( $user_id ) {
wp_set_current_user($user_id);
wp_set_auth_cookie($user_id);
wp_redirect( home_url() );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment