I have users with the role "authors" and a block in /user showing publications so that visitors can see the publications of every "author". The problem is that the block is showing at every user profile page even if the user has not an "author" role. How can i set this block to show only to user profile pages that have a role "author"?
On the configure block page, at the bottom in the vertical tab menu, click on the roles tab, and select which user role you want it to display for.
Call this function for visiblity settings: block visiblity settings > Pages > 'Pages on which this PHP code returns TRUE (experts only)'
function _user_block_visiblity() {
if (arg(0) === 'user') {
global $user;
if(in_array('authors', $user->roles){
return TRUE;
}
}
// Default is to not show the block
return FALSE;
}