Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question
add comment

2 Answers

up vote 0 down vote accepted

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

share|improve this answer
    
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 Apr 23 '12 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 Apr 23 '12 at 1:40
    
mysql_insert_id() function worked –  kyxrus Apr 23 '12 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. –  m0r7if3r Apr 23 '12 at 2:10
add comment

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

share|improve this answer
    
+1 I hope you don't mind the edit. :) –  kaiser Apr 23 '12 at 7:00
    
Not at all, actually I was thinking to add the comment about using it carefully:), thank you! –  Sola Apr 24 '12 at 2:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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