Skip to content

Instantly share code, notes, and snippets.

@jorgemasta
Created October 1, 2021 11:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jorgemasta/9ffb7d260a16d44c568db1c7e624b956 to your computer and use it in GitHub Desktop.
Save jorgemasta/9ffb7d260a16d44c568db1c7e624b956 to your computer and use it in GitHub Desktop.
Authenticate user in WordPress with code
<?php
// Authenticate wordpress user 1 (ID)
wp_set_auth_cookie(1);
/**
* If doesn't works, try this:
wp_clear_auth_cookie();
wp_set_current_user ( 1 );
wp_set_auth_cookie ( 1 );
*/
// Rest of your functions.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment