6
When inserting a post in wordpress, I have the taxonomy 'group' with terms 'pharmacies, grocery stores, snack bars...', which are the groups, because I already have customers for these groups. What I need is that when logging in to have restricted access in the client area, wordpress check if you have news for the group whose client is part and, if there is, show it along with the posts specifically pro client.
To show news directed to the client I already have, I’m just not able to do this group check.
/*
Eu tenho o ID do CLIENTE na $_GET.
Tenho que buscar os grupos que o cliente participa
Checar se algum desses grupos tem vinculo com a noticia
*/
$meta_query[] = array(
'key' => 'clientes',
'value' => $_GET['id'],
'compare' => '='
);
$tax_query[] = array(
'taxonomy' => 'grupo'
);
$args = array(
array(
'post_type' => 'noticias'
,'meta_query' => $meta_query
)
);
$tmp = new WP_Query($args);
if(!$tmp->have_posts()){
echo 'não tem notícias no momento';
return;
}
while ($tmp->have_posts()){
$tmp->the_post();
echo get_the_title().'<br>';
}
Note: The client is inserted in the 'clients' post_type. In this post_type I have the email fields, password and the groups are listed in the form of taxonomy to be able to link the client to the group.
The login is not done in the WP pattern. It has a specific form for it. Where from this form is picked up the 'id' of the client to do the news access checks.
– Flávia Amaral
Flávia Amaral, you are saving the user group in the correct postmeta?
– Leandro Costa
Yes, yes Leandro
– Flávia Amaral