6

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);
Phiter
  • 14,570
  • 14
  • 50
  • 84
Raymond Seger
  • 1,080
  • 5
  • 17
  • 34

1 Answers1

7

turns out WP sanitizes it automatically.

Raymond Seger
  • 1,080
  • 5
  • 17
  • 34