繁体   English   中英

当我使用 add_action 'user_register' (Wordpress) 时从其他表数据库获取数据

[英]Get data from other table DB when i use add_action 'user_register' (Wordpress)

不好意思,想问一下,我试过在function.php中使用这个脚本:

add_action( 'user_register', 'myplugin_registration_save', 10, 1 );

它起作用了,我想检索 wp_uap_affiliates 表中的推荐 ID 数据。 但是我意识到上面的 add_action 在 wp_uap_affiliates 表中有插入过程之前运行,所以我无法获得推荐 ID。

有没有人有办法解决吗? 提前致谢。

因为 add_action 比将推荐 id 插入数据库要早,所以我试图在 Ultimate Affiliate Pro 插件脚本中找到类似 do_action 的东西。

然后我找到了这个代码:

do_action('uap_on_register_action', $this->user_id);

然后我使用 'uap_on_register_action' 来替换 add_action 中的 'user_register'。

所以这是替换后的代码:

add_action( 'user_register', 'myplugin_registration_save', 10, 1 );

现在它起作用了。 谢谢。

我检查了它确实在那个钩子之后更新表。 你能试试下面 user_register 钩子中的代码吗?

             sleep(3);
             global $indeed_db;
             $affiliate_id = $indeed_db->get_affiliate_id_by_wpuid($user_id);

暂无
暂无

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

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