WordPress Hacks

This page will list common WordPress hacks to get things done.

Note that this page doesn’t list any hack for malicious activities, rather to make the life of legit owners easier.

How to make yourself admin via ftp

If you have ftp access to the wordpress files only, first of all find your user id by adding this code:

$user = get_user_by( 'login', 'your_login_here' );
echo 'User is ' . $user->id;

Refresh the site frontend and it will echo your user id, use it in next step:

$user = new WP_User( '1' ); // or the userid that you got from the step above
 $user->set_role( 'administrator' );

Voila! Now remove the code added to the theme and enjoy.

Create new admin user from any file

Add this code to the file via ftp and refresh the front-end.

function admin_account(){
$user = 'AccountID';
$pass = 'AccountPassword';
$email = '[email protected]';
if ( !username_exists( $user )  && !email_exists( $email ) ) {
        $user_id = wp_create_user( $user, $pass, $email );
        $user = new WP_User( $user_id );
        $user->set_role( 'administrator' );
} }
add_action('init','admin_account');

Let me know if there is any issue.

Leave a Reply

Your email address will not be published.