“Traducir” SQL Query a WP_meta_query

Tengo esta consulta SQL (de un complemento), que estoy tratando de traducir a una meta_query para obtener publicaciones en otra página.

Básicamente, estoy tratando de obtener todos los eventos que el usuario puede ver (generalmente dependiendo de si son parte de un grupo o no).

//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)))"; } } 

Esto es lo que tengo hasta ahora. No tengo ningún error de PHP, así que está bien. Pero devuelve 0 resultados. ¿Hay algún problema en mi “traducción”?

 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']).")))"; $meta_query = array( 'relation' => 'OR', array( 'relation' => 'OR', array( 'key' => 'event_private', 'value' => 0, 'compare' => '=', ) , array( 'relation' => 'AND', array( 'key' => 'event_private', 'value' => 1, 'compare' => '=', ) , array( 'relation' => 'OR', array( 'key' => 'group_id', 'compare' => 'NOT EXISTS', 'value' => 'null', ) , array( 'key' => 'group_id', 'compare' => '=', 'value' => '0', ) , ) , ) , ) , array( 'relation' => 'AND', array( 'key' => 'event_private', 'value' => 1, 'compare' => '=', ) , array( 'key' => 'group_id', 'value' => $group_ids['groups'], //array 'compare' => 'IN', ) , ) , ); } 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)))"; $meta_query = array( 'relation' => 'OR', array( 'key' => 'event_private', 'value' => 0, 'compare' => '=', ) , array( 'relation' => 'AND', array( 'key' => 'event_private', 'value' => 1, 'compare' => '=', ) , array( 'relation' => 'OR', array( 'key' => 'group_id', 'compare' => 'NOT EXISTS', 'value' => 'null', ) , array( 'key' => 'group_id', 'compare' => '=', 'value' => '0', ) , ) , ) , ); } }