How can 2 blogs share the same users

I have a running normal WP blog (blog 1). I want to create a Q&A section for my users, so I setup another blog with WP-Answer theme (blog 2).

The problem is I don’t want my users at blog 1 have to register at blog 2 to post questions. I want they automatically grant the same privileges at blog 2.

Read More

How can this be achieved? Do you have any advice for me?

Thank you very much.

Related posts

Leave a Reply

4 comments

  1. I think you want to install your second site on the same database but with a different table prefix, e.g. $table_prefix = "qa_"; in wp-config.php

    You are then able to define a custom user and/or user_meta table by adding the following lines to wp-config.php

    define('CUSTOM_USER_TABLE', [orig_table_prefix].'my_users');
    define('CUSTOM_USER_META_TABLE', [orig_table_prefix].'my_usermeta');
    

    Source: http://codex.wordpress.org/Editing_wp-config.php#Custom_User_and_Usermeta_Tables

    I have read somewhere before that you may have to sort out a couple of issues of admin users on the second site, can’t find the link at the moment.

  2. I think the easiest would be to keep one site, and only apply your Q&A styles to the pages you need. That way you keep everything centralized in one WP install.

    If you use body_class() you can target any page/post from your CSS and apply the styles you want only where you need them.

    It would go something like this, if your Q&A pages have a common template named question_answer.php you can style them like with :

    .page-template-question_answer{ background:#FAFAFA }
    .page-template-question_answer #conent{ width:500px }
    
  3. I’m guessing you’ll probably want them to be automatically logged in to the Q&A site, otherwise it’s not much better than registering twice. Your best bet is probably to change your original site to a multisite instance and have the Q&A site be another site within the same WordPress installation. Then find a plugin that will automatically grant a certain user role without you having to add them manually, such as http://wordpress.org/extend/plugins/multisite-user-management/

    Also see: http://codex.wordpress.org/Create_A_Network

    If you’re on shared hosting, it’s possible that you might run into difficulties getting multisite set up, but it’s still probably the best solution.

  4. Don’t forget that you’ll need not only the CUSTOM_USER_(META_)TABLE pointing to the main sites user table in the wp-config.php of your child site, but also the AUTH_KEY, SECURE_AUTH_KEY, LOGGED_IN_KEY, NONCE_KEY constants should be exactly the same as on your main site. This will avoid generating new passwords. Should work out of the box.