Version 1.0.35

This commit is contained in:
ultimatemember
2015-02-01 01:30:04 +02:00
parent df37a3164f
commit 539ebf10d7
41 changed files with 938 additions and 226 deletions
+53
View File
@@ -0,0 +1,53 @@
<?php
/***
*** @Search results
***/
add_action('pre_get_posts','um_pre_get_posts');
function um_pre_get_posts($query) {
if ( !is_admin() && $query->is_main_query() ) {
if ( $query->is_search || $query->is_archive() || $query->is_home ) {
if ( $query->is_home && !um_get_option('exclude_from_main_loop' ) ) return;
if ( $query->is_archive && !um_get_option('exclude_from_archive_loop' ) ) return;
if ( $query->is_search && !um_get_option('exclude_from_search_loop' ) ) return;
if ( is_user_logged_in() ) {
$meta_query['relation'] = 'OR';
$meta_query[] = array(
'key'=>'_um_accessible',
'value'=>'1',
'compare'=>'!=',
);
$meta_query[] = array(
'key'=>'_um_accessible',
'compare'=>'NOT EXISTS',
);
$query->set('meta_query',$meta_query);
}
if ( !is_user_logged_in() ) {
$meta_query['relation'] = 'OR';
$meta_query[] = array(
'key'=>'_um_accessible',
'value'=>'2',
'compare'=>'!=',
);
$meta_query[] = array(
'key'=>'_um_accessible',
'compare'=>'NOT EXISTS',
);
$query->set('meta_query',$meta_query);
}
}
}
}