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' ) );
$authid = $user_id;
do_action('user_register', $user_id);
// Insert into Post table
$post = array();
$post['post_author'] = $authid ;
$post['post_date'] = date('Y-m-d H:i:s') ;
$post['post_date_gmt'] = date('Y-m-d H:i:s') ;
$post['post_name'] = $username ;
$post['post_status'] = 'pending' ;
$post['post_title'] = $username ;
$post['post_type'] = 'post';
$post['post_category'] = $gender;
wp_insert_post( $post, $wp_error );
登録後、投稿テーブルにもユーザーを挿入しようとしています。ユーザー名を入力すると、ユーザーテーブルのようにtest'name
挿入されますが、投稿テーブルのように挿入されます。投稿テーブルの引用符も削除する必要があります。どうやってするか?testname
test\'name