clarklab
Member
Posted 2 years ago #
On the post page I'm looking for a way to add an author bio for users only with the role 'contributor'
This closest thing I've found was this and a few others posts but they were all geared towards comment authors.
we have a few writers (admins, editors) that post all the time and on those posts we don't need the author bio so a conditional to check the role would be perfect. any ideas?
You can do something like this:
<?php global $user_level;
<!--get_currentuserinfo() gets the currentuser info and automatically assigns the values to some global variables, including $user_level, above-->
get_currentuserinfo();
if ($user_level == 1) { ?><!--user level 1 equates to 'contributor'-->
<!--here's where you could put your bio link-->
<?php } ?>
Hope this helps.
clarklab
Member
Posted 2 years ago #
that works but it seems to check the role of the logged in user, not the author of the post.
clarklab
Member
Posted 2 years ago #
Ah I figured it out. This works just fine:
<?php $var = get_the_author_meta('user_level');
if ($var == 1) {
the_author_link();
}?>
OOps, I posted before I saw yours. :)