Php Wordpress表关联
我有一个部分完成的插件可湿性粉剂,集成容易!将约会计划实用程序导入WP数据库。我需要联想简单!与WP用户预约用户 结构: 简单!约会数据库是mysql中WP数据库结构的一部分。容易的!约会是在Codeigniter框架中构建的。容易的!约会在WP内的iframe中运行 轻松!约会,用户表是ea_users,我知道我需要在ea user表中为wp_id创建另一列。因此,我将创建该列Php Wordpress表关联,php,mysql,wordpress,codeigniter,Php,Mysql,Wordpress,Codeigniter,我有一个部分完成的插件可湿性粉剂,集成容易!将约会计划实用程序导入WP数据库。我需要联想简单!与WP用户预约用户 结构: 简单!约会数据库是mysql中WP数据库结构的一部分。容易的!约会是在Codeigniter框架中构建的。容易的!约会在WP内的iframe中运行 轻松!约会,用户表是ea_users,我知道我需要在ea user表中为wp_id创建另一列。因此,我将创建该列 ALTER TABLE `ea_users` ADD `wp_id` BIGINT(20) NOT NULL ;
ALTER TABLE `ea_users` ADD `wp_id` BIGINT(20) NOT NULL ;
在wp\u users
表中,我需要id
和user\u email
字段分别与ea\u users
表中的wp\u id
和email
字段关联
这可以在mysql中通过某种关联实现吗?(那太好了)
或者我需要一些php代码(在sudo代码中):
如果我必须做PHP,那么我想那就可以了。如果我的逻辑不正确,请告诉我。此外,我还必须记住如何做到这一点,以便任何快速的提示都会得到赞赏,但不是预期的
问题:
问题1的答案是否定的。
问题2的答案是我认为我的逻辑是正确的。
问题3的答案是肯定的,有一些内置的WP函数,我需要的是WP_get_current_user()和get_current_user_id()
所以,这个问题的大部分都得到了回答。现在,我对codeigniter集成有一些疑问。到目前为止我所做的尝试:在我的控制器中——添加require_一次(“/path to wp/wp includes/user.php”);$wp_id=get_current_user_id();上述操作不起作用,因为我在codeigniter中调用它,所以它显示我没有登录。但是,在插件代码中添加以下内容:
if(!function_exists('wp_get_current_user')){include(ABSPATH.wp includes/pluggable.php”)}$wp_id=get_current_user_id()
返回已登录的用户,但不会将其传递给codeigniter。所以,我想我误解了钩子是如何工作的。
On creating an E!A booking, check if the `wp_id` column for the user is null
if is null: Get the the `wp_users` table, `user_email` and current `id` and fill the `ea_users` table `wp_id` and `email`.
else: check for matching `wp_users` `id` and `ea_users` `wp_id`
if yes: match `ea_users` `wp_id` user with `wp_users` `id` and fill existing EA user data in to EA fields
if no: delete the `ea_users` `wp_id` and get the `wp_users` table, `user_email` and fill the `ea_users` table `wp_id` and `email`.