This block is a GREAT idea. On my site, it would help if there was a feature that allowed me to hide the block entirely for certain roles. Right now, I have anonymous (unique content in block), authenticated (also unique), but I don't need to show it for "Current Members". I can live with it showing by utilizing the token filter, but I don't really need this block to show to upper-level users. Can this feature be added, to hide it for specific roles?

Thanks,
Maria

Comments

nicholasthompson’s picture

This is something i'd like to add...

However as a workaround, would you be able to exclude the other role in the block configuration (not the block_cpr settings). I recall blocks having a setting to exclude certian roles...

mariagwyn’s picture

Status: Active » Postponed

I did figure out how to exclude it using PHP in block settings.

1. In the settings > Blocks, click "Configure" for the CPR block.
2. the following PHP excludes based on role, excluding for two types:

<?php 
  global $user; // instantiates the current user object
  if(in_array('member',$user->roles) || in_array('administrator',$user->roles)){ // checks to see if 'member' or 'administrator is in the user role array
    return false; // hide block for members
  }else{
    return true;  // shows block for everyone else
  }
?>

I would still love the feature, but this will work in the interim.

topdawg’s picture

This looks interesting whereas I am trying to achieve something like that but return based on specific pages in addition to the user role whereas the user role I am interested in is the root admin.

So there is a page called 'art_science_life' which is the only page to display any of this to anyone no matter. If the user is an admin it should NOT display it since the admin is using a different view. The node add is to maintain the view while a user is adding a content and is less of an issue.

Problem thus far - the block displays for admin user as well but only on the desired page. So it's one small step but I can't figure out why the admin is NOT excluded from the view. The argument for user admin works, this I know, so it must be something in the array for the pages called that's wrong, or that root admin has automatic view of my block which happens to be the navigation view within a block.

<?php
global $user;

//if ($user->uid !== 1); //pretty much the same result as admin
if ($is_admin == false);

  $match = FALSE;

  $types = array('art_science_life' => 1, 'art-science-life' => 1);
  $uris = array('/art_science_life' => 1, '/node/add/art-science-life' => 1);


if ((arg(0) == 'node') && is_numeric(arg(1))) {

    $node = node_load(arg(1));
    $match = isset($types[$node->type]);

}
  $match |= isset($uris[request_uri()]);
  return $match;
?>