Tips & Tutorial

How to Login into WordPress Without User and Password?

Oleh takien

Sometime we need to login to WordPress system without knowing username and password. Using these sort of functions you can bypass all authentication process and directly logged in into speficif user id.

Change $user_id value to desired user id, eg. 1 for admin.

if(!is_user_logged_in()) {
$user_id = 1;
wp_clear_auth_cookie();
wp_set_current_user( $user_id );
wp_set_auth_cookie( $user_id );
}

Place it somewhere in your theme or plugin, and, voila….. You’re logged in.

wordpress logo
wordpress logo

So what the heck this thing useful for?

  • To login into WordPress without using username and password. You don’t say.
  • To know site behavior for spesific user.
  • To make connection with social networking site like Facebook or Google Plus.

Tulisan ini sudah berumur: 12 tahun 1 bulan 23 hari. Informasi di dalamnya mungkin sudah tidak relevan, tapi nilai historisnya sangat berharga, terutama bagi saya sebagai penulisnya.

Tag Terkait: