简体   繁体   中英

Share Users FROM main “non-WP” website DB with Wordpress?

I have been using WP for awhile, but always as a "stand alone" site, and now am looking to make a blog as part of my main website and have been looking around for the best way to eliminate the register/log-in redundancy and ideally use my user data from my primary websites database for the WP installation in the easiest, and most secure, way possible. The WP blog is on the same server/in a subfolder of the main site.

I HAVE looked around for the solution before posting this, but it seems that most discussions around this topic involve sharing users between multiple WP sites rather than with a non-WP primary website.

A FEW possible options that I have found, but am not sure if will work, are the following:

1) A plugin (External DB Authentication) which seemed to be the ticket but apparently has not been updated for awhile and shows version 2.9.2 as the last compatible version. Are there other/better/maintained plug in alternatives to this? I couldn't find anything else that seemed as spot-on as this one. I DID attempt to get it to work, but was not able to log in on the WP installation:

I created and added a NEW user to my primary website DB, with the only permission checked being "select" and used all the primary website DB info on the form:

Name: myws_mysitedb | User: myws_newwpuser | password: password for new user | User Table: sitetable_logins

Username: username | Password: password | encryption type: Other | hash: exactly what the makers of the software used on my main site said to use

I also created a user through the main site registration system with exactly the same username and password as the admin name/password on the WP installation since it has to authenticate the admin user as well against the primary external DB.

See anything that I perhaps did wrong? I also attempted it with the new user having ALL permissions but no effect.

2) I have read about adding define('CUSTOM_USER_TABLE', $table_prefix.'my_users'); define('CUSTOM_USER_META_TABLE', $table_prefix.'my_usermeta'); define('CUSTOM_USER_TABLE', $table_prefix.'my_users'); define('CUSTOM_USER_META_TABLE', $table_prefix.'my_usermeta'); but do not understand if that will take care of the registration/log-in issue on the WP end in and of itself or not, am not sure if I HAVE to/should not use the "meta_table" if there is currently no such table in the main DB, and am not sure exactly how I am supposed to specify WHERE the other table to be used is... I have read that $table_prefix is again in reference to when multiple WP instances are on the same DB (or something like that) so don't think I need that in my case. I tested aa few things, changed it to: define('CUSTOM_USER_TABLE', custom_databasename.'custom_tablename');

define('CUSTOM_USER_TABLE', 'custom_databasename.custom_tablename');

and simply: define('CUSTOM_USER_TABLE', 'custom_user_table'); but neither allowed me to log-in with current users from my primary site.

I hope this question/request is not a nuisance, and that there isn't an OBVIOUS solution that I should have already found myself, but I am surprised that I couldn't readily find an easy step by step process for sharing users from my existing site/different database with a Wordpress blog....

I thank you in advance for any tips and help!

One (slightly hacky) way to do this might be to define insert/update triggers on your main site user tables.

Whenever a user is inserted or updated, create or update the corresponding record in the wordpress user database. You could create similar triggers on the Wordpress user tables as well if you wanted two-way integration.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM