Skip to content

Instantly share code, notes, and snippets.

@madalinignisca
Created September 4, 2013 19:20
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 madalinignisca/6441587 to your computer and use it in GitHub Desktop.
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…
<?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