WordPress – How To Manually Add New Admin User From MySQL Database

If somehow you are locked out of the WordPress admin but have access to the database, you can follow the below steps to manually create a new WordPress admin user account to regain access to the admin dashboard.

1. Open the table wp_users (where wp_ should be replaced with the table prefix used in the database)
2. Insert a new row with the following data –

ID – keep blank
user_login – the username for the new account
user_pass – the password for the new account (If you are using PHPMyAdmin choose MD5 from the Function dropdown. Or else convert the password to MD5 and then enter the converted value)
user_nicename – Enter a nickname for the account
user_email – The email address that you want to use with this account
user_status – 0 (zero)
display_name – Display name for the new user

Rest of the fields can be left blank

3. Note down the ID of the inserted row
4. Open table wp_usermeta (where wp_ should be replaced with the table prefix used in the database)
5. Insert a new row with the following data –

umeta_id – keep blank
user_id – Enter here the ID noted down in step 3.
meta_key – wp_capabilities (where wp_ should be replaced with the table prefix used in the database)
meta_value – a:1:{s:13:”administrator”;b:1;}

6. Insert another row with the following data –

umeta_id – keep blank
user_id – Enter here the ID noted down in step 3.
meta_key – wp_user_level (where wp_ should be replaced with the table prefix used in the database)
meta_value – 10

That is all it takes to add a new admin user with administrator role. Log in to WordPress admin now with the username / password provided in step 2.

Posted in Wordpress | Tagged , , | 3 Comments
 

How To Fix WordPress Admin Dashboard Showing Blank Page

If you have not upgraded your WordPress for quite some time and are still using an old version you might face this problem.

The Problem

The front end will function as usual, but the admin after logging in will only show the left menu panel. The right section will be completely blank.

The Solution

Via FTP or File Manage download and / or edit the following file –

/wp-admin/includes/screen.php

Search for the following –

self::$this->_help_sidebar

Replace this with

$this->_help_sidebar;

Save and / or upload the file.

That should solve the problem.

Also never ignore to upgrade WordPress to the latest version. It will keep your site safe from security and other threats.

Posted in Wordpress | Tagged , , , , | 3 Comments
 

WordPress How To Pass PHP Values To JavaScript In Plugins

While creating a plugin if you want to pass some values generated by PHP to a JavaScript file, the WordPress way, follow the below steps. It’s really very easy –

1. Put the values in an array For example –

 
$params = array('pluginpath' => plugins_url(),'abc' => $xyz); 

2. Register the JavaScript file. For example –

 
wp_register_script('jsfile', plugins_url('/', __FILE__) . 'js/jsfile.js');

3. Make the PHP data available to the registered script. For example –

 
wp_localize_script( 'jsfile', 'phpvalues', $params );

4. Link the script file. For example –

 
wp_enqueue_script('jsfile');

5. Use the values in JavaScript file as below –

alert(phpvalues.pluginpath);
alert(phpvalues.abc);

Full example code in PHP

 
function example_admin_init() {
     $params = array('pluginpath' => plugins_url(),'abc' => $xyz); 
     wp_register_script('jsfile', plugins_url('/', __FILE__) . 'js/jsfile.js');
     wp_localize_script( 'jsfile', 'phpvalues', $params );
     wp_enqueue_script('jsfile');
}
add_action('wp_enqueue_scripts', 'example_admin_init');

Hope it was clear. Happy coding 🙂

Posted in Wordpress | Tagged , , , | Leave a comment
 

Magento – How To Get Configuration Values

$conVal = Mage::getStoreConfig('section_name/group_name/field_name');
Posted in Magento | Tagged , , | Leave a comment
 

WordPress – Stuck In Maintenance Mode While Updating Plugins – Solution

Problem – While updating the WordPress plugins or themes the process breaks and the site is stuck in Maintenance mode and keeps showing the Maintenance mode message.

Solution – Via FTP or File Manager go to WordPress root folder. There should be a file called .maintenance Delete it and the maintenance mode will be removed.

Posted in Wordpress | Tagged | 1 Comment