Anyone know how to sanitize the $_POST
for wordpress? Or is it already sanitized when i used the WP_QUERY
? thanks!
I was thinking whether i use mysql_escape()
or esc_sql()
[wordpress function].
function checkIfEmailAndPasswordHaveUser( $email, $password ) {
$args = array(
'post_type' => 'my_custom_post_type',
'meta_query' => array(
array(
'key' => 'email',
'value' => $email
),
array(
'key' => 'password',
'value' => $password
),
),
);
$query = new WP_Query( $args );
if( !$query->have_posts() ) {
return false;
} else {
// return the user's ID
return $query->posts[0]->ID;
}
}
$post_user_email = trim( $_POST['user_email'] );
$post_user_password = trim( $_POST['user_password'] );
// check if user_id exist
$result = checkIfEmailAndPasswordHaveUser($post_user_email, $post_user_password);