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.

I have a live WordPress installation and a local one for development purposes. I just exported the live database, replaced all occurences of the live siteurl with the local one, and imported on my dev machine.

Problem is that on my dev machine all users have lost any permissions. When logging in I get:

Notice: Undefined offset: 2 in /var/www/mysite/wp-admin/includes/plugin.php on line 1390 

On a page template I dumped out the current userinfo with

global $current_user;
var_dump( get_currentuserinfo() );

This returns NULL on my dev machine and the correct userinfo on my live installation. I double checked the table prefixes, permissions, tried a clean WordPress installation, etc but had no luck. The confusing thing about this is, that I can query the userinfo perfectly fine with a custom sql query.

EDIT: Upon further inspection I found out that the global $wp_roles contains no user roles and capabilities. WordPress somehow can't retrieve this from the database...

EDIT 2: Sorry for the edits. But I found the problem. Inside the wp_options table there is a row "wp_user_roles". The value, an unserialized string did somehow include whitespaces which lead to errors when trying to unserialize the string. I replaced the database value with the live site's one and everything works now.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

I just exported the live database, replaced all occurences of the live siteurl with the local one, and imported on my dev machine.

Finding/replacing with a text editor breaks serialized data; you must change values with MySQL queries in phpmyadmin:

UPDATE wp_options SET option_value = replace(option_value, 'http://www.olddomain.com/', 'http://www.newdomain.com/') WHERE option_name = 'home' OR option_name = 'siteurl';

UPDATE wp_posts SET guid = replace(guid, 'http://www.olddomain.com/blog/','http://www.newdomain.com/');

UPDATE wp_posts SET post_content = replace(post_content, 'http://www.olddomain.com/blog/', 'http://www.newdomain.com/');

UPDATE wp_postmeta SET meta_value = replace(meta_value, 'http://www.olddomain.com/blog/', 'http://www.newdomain.com/');
share|improve this answer
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.