Created
September 4, 2013 19:20
-
-
Save madalinignisca/6441587 to your computer and use it in GitHub Desktop.
"anonymous" user faked on a real user. use something like Justin's members plugin to create a custom role or wait until I'll add more code to help with many important permissions. I'm putting this together for a project I'm doing (or done when you're reading this) to be able to post anonymous using a custom child theme based on p2. something lik…
This file contains 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 | |
function auto_login() { | |
if (!is_user_logged_in()) { | |
//determine WordPress user account to impersonate | |
$user_login = 'anonymous'; | |
//get user's ID | |
$user = get_userdatabylogin($user_login); | |
$user_id = $user->ID; | |
//login | |
wp_set_current_user($user_id, $user_login); | |
wp_set_auth_cookie($user_id); | |
do_action('wp_login', $user_login); | |
} | |
} | |
add_action('init', 'auto_login'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment