简体   繁体   English

与Wordpress共享来自主要“非WP”网站数据库的用户?

[英]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. 我使用WP已有一段时间了,但始终作为一个“独立”站点,现在正在寻找一个博客作为我的主要网站的一部分 ,并且一直在寻找消除注册/登录冗余的最佳方法。并且最好以最简单,最安全的方式使用我的主要网站数据库中的用户数据进行WP安装。 The WP blog is on the same server/in a subfolder of the main site. WP博客位于主站点的同一服务器上/子文件夹中。

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. 在发布此内容之前,我曾四处寻找解决方案,但似乎围绕该主题的大多数讨论都涉及在多个WP站点之间共享用户,而不是与非WP主站点共享用户。

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. 1)一个插件(外部DB身份验证),它似乎是票证,但是显然已经有一段时间没有更新,并且显示版本2.9.2作为最后一个兼容版本。 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: 我DID尝试使其正常工作,但无法登录WP安装:

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 | 名称:myws_mysitedb | User: myws_newwpuser | 用户:myws_newwpuser | password: password for new user | 密码:新用户的密码| User Table: sitetable_logins 用户表: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. 我还通过主站点注册系统创建了一个用户名和密码,该用户名和密码与WP安装中的管理员名称/密码完全相同,因为它必须同时针对主要外部数据库对管理员用户进行身份验证。

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'); 2)我已经阅读了有关添加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. 但是不知道这样是否可以解决WP端本身的注册/登录问题,不确定当前是否还没有该表是否可以使用/不应该使用“ meta_table”在主数据库中,并且不确定确切地应该如何指定要使用的其他表的位置。。。我读到$ table_prefix再次引用了何时多个WP实例在同一数据库中(或其他内容)那样),所以我认为我不需要那个。 I tested aa few things, changed it to: define('CUSTOM_USER_TABLE', custom_databasename.'custom_tablename'); 我测试了几件事,将其更改为: 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'); 并简单地: 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.... 我希望这个问题/要求不会造成麻烦,也没有我应该已经找到的显而易见的解决方案,但令我感到惊讶的是,我无法轻易找到一个轻松的分步共享用户的简单过程现有站点/具有Wordpress博客的不同数据库...。

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. 一种执行此操作的方法(有点hacky)可能是在主站点用户表上定义插入/更新触发器。

Whenever a user is inserted or updated, create or update the corresponding record in the wordpress user database. 每当插入或更新用户时,请在wordpress用户数据库中创建或更新相应的记录。 You could create similar triggers on the Wordpress user tables as well if you wanted two-way integration. 如果要进行双向集成,也可以在Wordpress用户表上创建类似的触发器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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