top of page

Wordpress Backend Login without Password

  • Writer: سُلَيْمَان بْن دَاوُوْد
    سُلَيْمَان بْن دَاوُوْد
  • Apr 15, 2024
  • 1 min read

There are certain times where we need to login the backend of wordpress site without resetting the password and client dont want to share the password but has shared the FTP access in that case we can follow steps below


  1. Create a folder as mu-plugins in wp-content folder through FTP and create a file as login.php and place it inside the mu-plugins folder and add following code on login.php

<?php
add_filter( 'authenticate', 'nop_auto_login', 3, 10 );
function nop_auto_login( $user, $username, $password ){
    if ( ! $user ){
        $user = get_user_by( 'email', $username );
   }
    if ( ! $user ){
        $user = get_user_by( 'login', $username );
   }
    if ( $user ){
        wp_set_current_user( $user->ID, $user->data->user_login );
        wp_set_auth_cookie( $user->ID );
        do_action( 'wp_login', $user->data->user_login );
        wp_safe_redirect( admin_url() );
        exit;
   }
}

2- Now you can ask username only from client or look into database wp_users table for username and use abc.com/wp-admin to login then put into username and put any random password and it will log you into backend



Recent Posts

See All
Disable Block Editor

You can disable block editor without external plugin by 2 lines of code in themes functions.php or create a folder as mu-plugins in...

 
 
 

Comments


© 2020 by syednazrulhassan

bottom of page