Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/299.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 用户表wordpress中最后一次插入id问题_Php_Wordpress - Fatal编程技术网

Php 用户表wordpress中最后一次插入id问题

Php 用户表wordpress中最后一次插入id问题,php,wordpress,Php,Wordpress,我在wordpress网站上有一份注册表格。我使用以下代码插入用户 $username = $wpdb->escape(trim($_POST['txtFullName'])); $email = $wpdb->escape(trim($_POST['txtEmail'])); $password = $wpdb->escape(trim($_POST['txtPassword'])); $confirmpassword = $wpdb->escape(trim($_PO

我在wordpress网站上有一份注册表格。我使用以下代码插入用户

$username = $wpdb->escape(trim($_POST['txtFullName']));
$email = $wpdb->escape(trim($_POST['txtEmail']));
$password = $wpdb->escape(trim($_POST['txtPassword']));
$confirmpassword = $wpdb->escape(trim($_POST['txtConfirmPassword']));
$gender = $wpdb->escape(trim($_POST['gender']));

 $user_id = wp_insert_user( array ('user_pass' => apply_filters('pre_user_user_pass', $password), 'user_login' => apply_filters('pre_user_user_login', $username), 'user_email' => apply_filters('pre_user_user_email', $email), 'role' => 'author' ) );
我使用以下代码来获取上面一行下插入的id

$authid = $wpdb->insert_id;

用户表中的自动增量主键与插入的id不同。我无法跟踪错误。如何修复此问题?

wp\u insert\u user()返回新创建用户的ID。在您的示例中,
$user\u id
已包含新id。

是否
$user\u id
已插入id?您使用
$wpdb->insert_id
做什么?为我的新朋友道歉。现在很好用。谢谢你的回复。