0

Does someone knows what part of wordpress code would I have to modify to be able to just enter into the admin panel without having to login?

I need to work on a site but I wont have admin access until a few day (when my friend comes back from vacations), but I do have FTP access (only FTP, no cpanel or any other type of panel to get into the db and change the pwd) and have his permissions to do whatever I need to login.

I checked wp-login.php file but couldn't find what to modify to allow me to login.

Does someone knows what file shoul

2 Answers 2

0

I have not tried it, but this thread on stackoverflow.com seems to be what you need - Create new admin, wordpress

4
  • Thanks that looks good, but the linked site containing the required db class doesn't seem to be working. I will see if I can reproduce what it does without that.
    – kyxrus
    Commented Apr 23, 2012 at 1:21
  • I am having troubles retrieving the inserted new ID, I found db class on google and I am trying to reproduce what you showed me, here's the code : pastie.org/private/noxfa5lhmcqhgxa6oh6bq do you know how to retrieve the new inserted user id?
    – kyxrus
    Commented Apr 23, 2012 at 1:40
  • mysql_insert_id() function worked
    – kyxrus
    Commented Apr 23, 2012 at 1:43
  • If this was your solution, please mark it accordingly so that anyone who finds this question and has the same issue can benefit from your knowledge.
    – mor7ifer
    Commented Apr 23, 2012 at 2:10
1

Note: The following script should only be used in a local development environment.

Maybe you can try the auto-login script, just copy the code below to a php file like autologin.php,and put the file in the root directory, then navigate to http://yoursite.com/autologin.php and you will be logged in automatically as administrator

<?php
require('wp-blog-header.php');
$query_str = "SELECT ID FROM $wpdb->users";
$user_ids = $wpdb->get_results( $query_str);
foreach (  $user_ids as $uid ) {
    $user_id = $uid->ID;
    if( user_can($user_id, 'administrator') ){
        $user_info = get_userdata($user_id);
        $user_login = $user_info->user_login;
        wp_set_current_user($user_id, $user_login);
        wp_set_auth_cookie($user_id);
        do_action('wp_login', $user_login);
        echo "You are logged in as $user_login";
        if( function_exists('get_admin_url') ){
            wp_redirect( get_admin_url() );
        } else {
            wp_redirect( get_bloginfo('wpurl').'/wp-admin' );
        }
        exit;
    }
}
?>

BTW, the sql query is not necessory if you know the user ID of administrator

1
  • Not at all, actually I was thinking to add the comment about using it carefully:), thank you!
    – Sola
    Commented Apr 24, 2012 at 2:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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