Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Share wordpress site between two different user tables

I have a wordpress site, and a iphone app for the same.Both have a common database with different user tables.

1> mysite.com >> wp_user

2> iPhone app >> app_user

what i want that, i want to make able app user login to the WordPress site. means

1> site user can only able to login into site

2> app user can login into site + iPhone app

how can i make app user able to login into site.

i have tried by debugging WP-login script, but can't find correct way

i need help from you guys.

thanks.

like image 261
Krunal Shah Avatar asked Dec 03 '13 06:12

Krunal Shah


People also ask

How to share WordPress users between two websites?

Just make sure you have WordPress installed in a Subfolder or Subdomain. Open Site B ‘s wp-config.php, and replace database name, user, and password to be the same as Site A. Now both sites will be using the same Database. Make sure Site B uses a different table prefix. 3. Share WordPress Users between the websites /* That’s all, stop editing!

How to share the same users and usermeta tables between two websites?

This means that if two (or more) WordPress websites share one database, we can set the same users and usermeta tables for all of them. As a consequence, all websites which share these table will share the same users. Note: In order to share the same users and usermeta tables, WordPress installations must share the same database.

How do I install two websites on one Wordpress site?

First of all make sure you are using the same WordPress version on the two websites and make sure your two websites are using the same database. To be able to have the two websites using the same database, you have to use different table prefix for each install.

How to connect two websites using the same database?

First of all make sure you are using the same WordPress version on the two websites and make sure your two websites are using the same database. To be able to have the two websites using the same database, you have to use different table prefix for each install. To change the default WordPress table prefix, you have two choice.


3 Answers

The required functionality looks a bit tricky, there might be more methods possible but the one I will recommend is:

  • Create a custom login form in wordpress site

  • Retrieve the username and password and first check if they exists on your site or not. If they do exist then simply login (these are site users) wp_signon method can be used here.

  • If they are not wordpress users then check if they are mobile app user by using MySQL and looking into the mobile app table, if they do exists then retrieve their information and register them into WordPress site wp_create_user can be used for it, you can add custom meta data so that you know these are app users. After registering, create login session using wp_signon.

I will recommend you to build a plugin for this task in wordpress.

Happy coding !

like image 62
Syed Qarib Avatar answered Oct 21 '22 13:10

Syed Qarib


You could use extend the WordPress XML-RPC API to authenticate your iphone user to wordpress. Detailed explanation and basic working code can be found at Extending the WordPress XML-RPC API (http://www.skyverge.com/blog/extending-the-wordpress-xml-rpc-api/).

like image 2
Skittish Avatar answered Oct 21 '22 13:10

Skittish


I would recommend a custom login plugin to accomplish this.

You can use wp-rename login plugin as a start up point for this.

In this plugin the WP credentials validation part is handled In the file rwl-login.php at line 449.

Similarly you have to add code to validate the mobile credentials as well in this switch case. If you have built your code adhering to WP mobile app standards you can just include login validation file as it is done for WP regular validation in line 450

if not do your own validation and redirect properly in that case You may also have your native app register the handler of that custom url so that it can catch and handle the redirect appropriately

like image 1
Mahesh Budeti Avatar answered Oct 21 '22 14:10

Mahesh Budeti