Answer the question
In order to leave comments, you need to log in
How to display metafields on the author's page if a certain role is assigned to him?
Good day. Can you please tell me how to display certain meta fields on the author's page if the author has been assigned a certain role? And how not to display if it's just a member? The participant is registered. He has a personal account, he fills in the fields, then he is assigned a role and the fields are displayed in the frontend.
I found the if( is_user_role( 'custom_role' ) ) construct, but there is a lot of html and I'm new to PHP and I don't really understand how to display it. Through echo or something else? Would it be correct to output the html container with such a condition?
Answer the question
In order to leave comments, you need to log in
if ( is_user_role( 'custom_role' ) ) {
echo '<p>' . get_user_meta( get_current_user_id(), 'custom_meta', true ) . '</p>';
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question