将SQL条件添加到WP_Query

时间:2017-09-23 09:16:04

标签: php sql wordpress

我有那些根据用户是否是组成员获取事件的SQL条件。

//deal with private groups and events
if( is_user_logged_in() ){
    global $wpdb;
    //find out what private groups they belong to, and don't show private group events not in their memberships
    $group_ids = BP_Groups_Member::get_group_ids(get_current_user_id());
    if( $group_ids['total'] > 0){
        $conditions['group_privacy'] = "(`event_private`=0 OR (`event_private`=1 AND (`group_id` IS NULL OR `group_id` = 0)) OR (`event_private`=1 AND `group_id` IN (".implode(',',$group_ids['groups']).")))";
    }else{
        //find out what private groups they belong to, and don't show private group events not in their memberships
        $conditions['group_privacy'] = "(`event_private`=0 OR (`event_private`=1 AND (`group_id` IS NULL OR `group_id` = 0)))";
    } 
}

如何将这些条件添加到WP_Query?它甚至可能吗?

0 个答案:

没有答案