Last active
December 18, 2015 04:23
-
-
Save alexphelps/ba501813b9b32598d8a9 to your computer and use it in GitHub Desktop.
Wordpress Query with Prepare
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* SQL query using $wpdb->prepare to protect it from sql injection | |
*/ | |
private function get_users_pending( $user_id ) { | |
global $wpdb; | |
$the_post_type = 'post'; | |
$status = 'pending'; | |
return $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_title FROM $wpdb->posts WHERE post_type = %s AND post_status = %s AND post_author = %s ORDER BY post_modified DESC", $the_post_type, $status, $user_id ) ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment