我怎样才能访问刚刚完成Gravity Forms注册表单的用户的ID ?


How can I access the ID of the user that just completed registration form in Gravity Forms?

我正在使用Gravity Forms注册插件在我正在构建的网站上注册用户,我正在尝试将新创建的用户的ID添加到通过电子邮件发送到特定电子邮件的URL。

我发现info herehttp://www.gravityhelp.com/documentation/page/Entry_Object,说你可以得到当前登录用户的用户ID,但是值返回0,因为它似乎好像用户没有完全登录在这个函数被调用。

这是我目前试图访问ID

的方式
add_action("gform_after_submission", "set_post_content_stuff", 10, 2);
function set_post_content_stuff($entry, $form){
//get id of user submitting the form
$currUserID = $entry['created_by'];
}

有谁知道注册新用户时如何从wp_users表访问ID吗?

您可以使用gform_user_registered钩子访问最近创建的用户id:

add_action( 'gform_user_registered', 'send_user_email', 10, 4 );
function send_user_email($user_id, $feed, $entry, $user_pass) {
    // Add function to send email
}

参见文档:https://www.gravityhelp.com/documentation/article/gform_user_registered/