Perhaps a “current_user_can(‘edit_posts’) condition could be inserted into the se_search_draft_posts() function?
That worked!
I changed:
//search drafts
function se_search_draft_posts( $where ) {
global $wpdb;
if ( !empty( $this->query_instance->query_vars['s'] ) ) {
$where = str_replace( '"', '\'', $where );
if ( !$this->wp_ver28 ) {
$where = str_replace( " AND (post_status = 'publish'", " AND ((post_status = 'publish' OR post_status = 'draft')", $where );
}
else {
$where = str_replace( " AND ($wpdb->posts.post_status = 'publish'", " AND ($wpdb->posts.post_status = 'publish' OR $wpdb->posts.post_status = 'draft'", $where );
}
$where = str_replace( " AND (post_status = 'publish'", " AND (post_status = 'publish' OR post_status = 'draft'", $where );
}
$this->se_log( "drafts where: ".$where );
return $where;
}
to:
//search drafts
function se_search_draft_posts( $where ) {
global $wpdb;
if ( !empty( $this->query_instance->query_vars['s'] ) ) {
$where = str_replace( '"', '\'', $where );
if (current_user_can('edit_posts')):
if ( !$this->wp_ver28 ) {
$where = str_replace( " AND (post_status = 'publish'", " AND ((post_status = 'publish' OR post_status = 'draft')", $where );
}
else {
$where = str_replace( " AND ($wpdb->posts.post_status = 'publish'", " AND ($wpdb->posts.post_status = 'publish' OR $wpdb->posts.post_status = 'draft'", $where );
}
$where = str_replace( " AND (post_status = 'publish'", " AND (post_status = 'publish' OR post_status = 'draft'", $where );
endif; //end of added condition
}
$this->se_log( "drafts where: ".$where );
return $where;
}
Hey,
thanks for the heads up – I will test this on my side and if everything checks out, it will most likely get implemented in the next update.
Once again, thanks for the feedback,
Petra
You decided not to implement this?