I want to unpublish profiles of users that doesn't have all extra fields that I've created filled.
I use a custom meta_query
in a user taxonomy in order to filter those authors, and that work, but it doesn't in author
templates.
function unpublish_not_full_authors( $query ) {
if ( $query->is_author() && $query->is_main_query() ) {
// your code to set $current_user_name here
$query->set( 'meta_query', array(
'relation' => 'AND',
array(
'key' => 'descripcion_breve',
'compare' => 'EXISTS',
),
array(
'key' => 'titulacion_preparador',
'compare' => 'EXISTS',
),
)
);
}
}
add_action( 'pre_get_posts', 'unpublish_not_full_authors' );
EDIT TO CLARIFY:
When a users register in my site he/she gets an URL to his website: example.com/author/my_profile.
What I want is to "un-publish" this public profile until the author doesn't have filled a few fields that I've created using ACF.
pre_get_posts
action has nothing to do with users but posts only. You say you created extra fields, show us how you did that.