开发者

Wordpress custom user table

I have defined a custom user table in my wp-config.

define('CUSTOM_USER_TABLE', 'wp_users');
define('CUSTOM_USER_META_TABLE', 'wp_usermeta');

But, when i try开发者_开发百科 to print out the logged in user info, user_level seems to be missing and the roles is empty. Any idea?

Any help is appreciated!!!!


If you are using only a single users table for multiple WordPress installations, WordPress will only generate the user role for the WordPress installation that you create the user on.

So, if you create john_doe on site1, john_doe will be assigned a user role on site1 (be it administrator, editor, author, etc), but site2 will not assign john_doe a user role. This is known as an "orphaned role." When john_doe logs into site2, he will receive a You do not have sufficient permissions to access this page error message.

So, you can either manually add the role into the usermeta database, or have an admin update the user's role for that installation, or finally you can use a plugin. I found a plugin that makes managing orphaned user roles much easier. It is called WP-Orphanage Extended.

I also created a video screencast explaining the whole issue, and showing how to use a single users table for multiple WordPress sites. You can find it here: http://mikemclin.net/single-users-table-multiple-wordpress-sites/


user roles are stored in wp_options with option_name: wp_user_roles Does that exist, or is it empty? Are all your tables prefixed with 'wp_'?

if so.
In wp_usermeta you have to set meta_key: wp_user_level
Also check meta_key wp_capabilities

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜