Most of the code I can find are about specific content being showed to the logged in user based on their role.
I want to do the opposite.
This is basically what I want to do:
If author has "Subscriber" role, show some html A. If author has "Customer" role, show html B.
I think this should be possible but I am not sure where to begin.
Here's the snippet I am using but not working so might have error somewhere?
<?php $current_author_roles = get_the_author_meta('roles');?>
<?php if ( in_array('Customer', $current_author_roles) ) { ?>
//do something
<?php } else { ?>
//do something else
<?php } ?>
Use a conditional. For example:
$current_author_roles = get_the_author_meta('roles');
if ( in_array('Customer', $current_author_roles) ) {
// do something
}
You can read more about get_the_author_meta() in the Codex.