2

Im sorry that I am asking this but I have been searching for ages and for some reaseon the suggested custom user table dosn't work, it just gives me a username error.

This is the code I am taking about:

define('CUSTOM_USER_TABLE','new_user_table');
define('CUSTOM_USER_META_TABLE', 'new_usermeta_table');

So I have a main Single install of Wordpress, Lets say I have another on a subdomain (Subdomain A) and a different WordPress site which IS a Sub Directory MU Install on Sub Domain B. I only want people to create an account at the top, main site however they can log in on any of the domains. I would use MU but one of the sub sites is using MU so I cant. Single Sign on is not important but if possible then that would also be really good.

Any Ideas would be appreciated!

Cheers, Joe

1

2 Answers 2

1

When you create a new user in such a shared user table, the roles and capabilities are set for one site only. The name and the ID will be available on all sites, but without any privileges the user cannot do anything useful.

You have to hook into 'user_register' and copy the roles and related data for all sites with custom code. You get the new user ID as a parameter.

3
  • So, I looked into what you where saying and added the permissions to the database as a_capabilities and b_capabilities. These are identical to that of the default database however when I log in (I can now log in, before it said Username not found) it says I don't have permission. Is it the user pass under the users table? Or what else could it be? Thanks for the help so far!
    – Joe Izzard
    Commented Aug 2, 2012 at 9:35
  • You need the user_level too, if I remember it correctly.
    – fuxia
    Commented Aug 2, 2012 at 11:26
  • I have added the user_level and it still says I don't have permission. I have also added the dashboard_quick_press_last_post_id but that didn't do anything.
    – Joe Izzard
    Commented Aug 2, 2012 at 11:43
-1

OK Guys. There is a way to do this without editing the core files!

1) Open up your WP-config.php file and add to the file the following code. This will change where WordPress gets it's users from.

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

Remember to replace the wp_ prefix with the prefix of your main site.

2) So no download and install the WordPress Plugin WP-Orphanage Extended (http://wordpress.org/extend/plugins/wp-orphanage-extended/). This will allow you to sync the user privileges across all of the sites.

3) Go to Settings > WP-Orphanage Extended and set the default role (Subscriber is probably the best choice. Now add two prefix's, one being the original/master sites prefix and the other being the sub sites prefix.

That is all there is to it now. Sorry for the inconvenience with the previous way of editing core files. Non of that is needed now.

1
  • 1
    Please don't do this. Changing the core is never a good idea. You can get around your CUSTOM_CAPABILITIES_PREFIX by just changing the $table_prefix variable in wp-config. See the codex example: codex.wordpress.org/… Then hook into user_register, as @toscho suggested, and set the capabilities for the other site. Commented Aug 2, 2012 at 22:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.