Is there a way to allow anyone into the admin panel, without the need to log in?

Or, if need be, is there a way to have Wordpress auto-login using a certain set of credentials?

This seems like something that should be trivial, but it appears nobody else has found a use case for this as of yet.

  • Oh, and yes, I am aware of the implications; there really is a valid use-case for this. I promise ;) – Qix Oct 24 '14 at 4:26
  • how is it different from simply giving user and password info? maybe there is a use case but right now it is totally not obvious – Mark Kaplun Oct 24 '14 at 5:54
  • @MarkKaplun Because it's an internal tool we're using more as a CMS and less as a blog. For its particular purpose, there's no point for credentials. – Qix Oct 24 '14 at 6:01
  • "For its particular purpose, there's no point for credentials" - I am sure this is what they said at target ;). And you didn't really answered my question about why not to give user and password as public info – Mark Kaplun Oct 24 '14 at 6:40
  • This is easily done. You could create a user with a specific WP role. Then hook into the 'authenticate' filter. In the function return the created user. The other component is that you would need to modify the login form so that it is not a form... just a login button or login link. – user42826 Oct 24 '14 at 9:12
up vote 2 down vote accepted

Here is example code that will log everyone in as 'autologinuser'. The 'autologinuser' needs to be created and given a role prior to using this code.

function my_autologin() {
    if (!is_user_logged_in()) {
        $uid = 'autologinuser';
        $user = get_userdatabylogin( $uid );
        wp_set_auth_cookie($user->ID);
        wp_set_current_user($user->ID);
        do_action('wp_login', $user_login);  // optional
    }
}
add_action('init','my_autologin');
  • This doesn't bypass the login form though – Qix Oct 24 '14 at 16:13
  • That code above, should work with the WP login form. I believe you should be able to leave the username/password fields empty and click on the submit button. Note that there was a typo that I corrected. I have code that modifies the login form, but it contains our css so it wouldnt be that useful. Would you want me to show you the code, minus css? – user42826 Oct 24 '14 at 16:29
  • Again, the point isn't to modify the login form but instead bypass it altogether. – Qix Oct 24 '14 at 16:31
  • 1
    Misunderstood you initially. I updated the code now to autologin users transparently. – user42826 Oct 24 '14 at 16:42
  • There we go :) That's enough to work with. Thank you! – Qix Oct 24 '14 at 16:47

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.