If you can't login to Wordpress admin, or rather, you are logged in, but can't do anything, like you've lost all permissions, you have probably changed the table prefix in your wordpress config.
To remedy this, you also need to change a few rows in MySQL:
In the table usermeta
UPDATE `wordpress`.`NEWPREFIX_usermeta` SET `meta_key` = 'NEWPREFIX_capabilities' WHERE `NEWPREFIX_usermeta`.`meta_key` = 'OLDPREFIX_capabilities';
UPDATE `wordpress`.`NEWPREFIX_usermeta` SET `meta_key` = 'NEWPREFIX_user_level' WHERE `NEWPREFIX_usermeta`.`meta_key` = 'OLDPREFIX_user_level';
UPDATE `wordpress`.`NEWPREFIX_usermeta` SET `meta_key` = 'NEWPREFIX_user-settings' WHERE `NEWPREFIX_usermeta`.`meta_key` = 'OLDPREFIX_user-settings';
UPDATE `wordpress`.`NEWPREFIX_usermeta` SET `meta_key` = 'NEWPREFIX_user-settings-time' WHERE `NEWPREFIX_usermeta`.`meta_key` = 'OLDPREFIX_user-settings-time';
UPDATE `wordpress`.`NEWPREFIX_usermeta` SET `meta_key` = 'NEWPREFIX_dashboard_quick_press_last_post_id' WHERE `NEWPREFIX_usermeta`.`meta_key` = 'OLDPREFIX_dashboard_quick_press_last_post_id';
In the table options
UPDATE `wordpress`.`NEWPREFIX_options` SET option_name = 'NEWPREFIX_user_roles' WHERE option_name = 'OLDPREFIX_user_roles'
Showing posts with label wordpress. Show all posts
Showing posts with label wordpress. Show all posts
Sep 14, 2017
Mar 14, 2016
WordPress jQuery UI tabs is not a function
When working with jQuery UI you get an error message:
Uncaught TypeError: jQuery(...).tabs is not a function(…)
This is because WordPress' function
wp_enqueue_script( 'jquery-ui' );
doesn't actually enqueue the tabs widget, only the core of jQuery UI.
So after that you need to add:
wp_enqueue_script( 'jquery-ui-tabs' );
See this link below for more info:
Default Scripts Included and Registered by WordPress
https://developer.wordpress.org/reference/functions/wp_enqueue_script/
Uncaught TypeError: jQuery(...).tabs is not a function(…)
This is because WordPress' function
wp_enqueue_script( 'jquery-ui' );
doesn't actually enqueue the tabs widget, only the core of jQuery UI.
So after that you need to add:
wp_enqueue_script( 'jquery-ui-tabs' );
See this link below for more info:
Default Scripts Included and Registered by WordPress
https://developer.wordpress.org/reference/functions/wp_enqueue_script/
Feb 18, 2016
Using Wordpress AJAX on Frontend
wp_ajax_* callback functions will return 0 if they are called on the frontend by anonymous users.
This is because of security reasons, but Wordpress has prefixes for "unsecure" calls: wp_ajax_nopriv_*.
Both of the hooks need to be defined to work with logged in and anonymous users.
In functions.php define:
Another thing to add is the ajaxurl variable, which is not included on the frontend by default. You can do this in many ways, but I figured the best thing to do is to use wp_localize_script().
Then, you can call the AJAX request like this:
This is because of security reasons, but Wordpress has prefixes for "unsecure" calls: wp_ajax_nopriv_*.
Both of the hooks need to be defined to work with logged in and anonymous users.
In functions.php define:
add_action( 'wp_ajax_call_stuff', 'my_callback' ); add_action( 'wp_ajax_nopriv_call_stuff', 'my_callback' ); function my_callback() { print_r($_POST); exit; }
Another thing to add is the ajaxurl variable, which is not included on the frontend by default. You can do this in many ways, but I figured the best thing to do is to use wp_localize_script().
wp_localize_script('my_main_script', 'myPrefix', array( 'ajaxurl' => admin_url( 'admin-ajax.php')));
Then, you can call the AJAX request like this:
jQuery.post(myPrefix.ajaxurl, { 'action': 'call_stuff', 'whatever': '1' }, function(response){ alert('The server responded: ' + response); } );
Oct 10, 2013
Wordpress update - old jQuery warnings
With the recent Wordpress update, jQuery was also updated to version 1.10.
Blogs were now full of warning messages, somewhere along the lines of:
ATTENTION! (by Comprehensive Google Map Plugin)
Your blog/site theme or one of your plugins uses jQuery javascript library which is older than the version 1.3.0.
The Comprehensive Google Map plugin will not work with such outdated jQuery version.
The minimum jQuery requirement for Comprehensive Google Map plugin is version 1.3.0. Apologies for the inconvenience..
However, this is not true. Version 1.10.2 is greater than 1.3, but somehow it get's detected as 1.1, because silly programmers cast the version code into float. Ugh.
Or wait for the plugin developers to FIX THE DAMN CODE.
Like that will happen anytime soon.
Blogs were now full of warning messages, somewhere along the lines of:
ATTENTION! (by Comprehensive Google Map Plugin)
Your blog/site theme or one of your plugins uses jQuery javascript library which is older than the version 1.3.0.
The Comprehensive Google Map plugin will not work with such outdated jQuery version.
The minimum jQuery requirement for Comprehensive Google Map plugin is version 1.3.0. Apologies for the inconvenience..
However, this is not true. Version 1.10.2 is greater than 1.3, but somehow it get's detected as 1.1, because silly programmers cast the version code into float. Ugh.
if (version < 1.3) { // WTF ?!?!?!?!?!
alert(CGMPGlobal.errors.oldJquery);
return false;
}
Unfortunately, there's not much we can do about it, other than a quick hack of removing the version check or modifying it to 1.1.Or wait for the plugin developers to FIX THE DAMN CODE.
Like that will happen anytime soon.
Apr 17, 2013
wp-admin: You do not have sufficient permissions to access this page
When migrating a Wordpress instalation some things could go wrong.
If you changed the table prefix, you might be getting this error when logging in the wordpress admin:
You do not have sufficient permissions to access this page
Solution:
Open phpmyadmin or something like that and go through the values in tables:
PREFIX_options
PREFIX_usermeta
find values that start with the old prefix, for example wp_ and change it to the new prefix.
in
wp_usermeta I changed all meta_key values from wp_* to newprefix_*
and in
wp_options I changed wp_user_roles to newprefix_user_roles.
If you changed the table prefix, you might be getting this error when logging in the wordpress admin:
You do not have sufficient permissions to access this page
Solution:
Open phpmyadmin or something like that and go through the values in tables:
PREFIX_options
PREFIX_usermeta
find values that start with the old prefix, for example wp_ and change it to the new prefix.
in
wp_usermeta I changed all meta_key values from wp_* to newprefix_*
and in
wp_options I changed wp_user_roles to newprefix_user_roles.
Subscribe to:
Posts (Atom)