I'm trying to display content in Advanced Profile based on the role of the person being viewed (so if we're viewing Role1, display aditional content, if we're viewing Role2 don't display that content). Can I go about doing this using either Views or Panels? And if so, how? I haven't been able ot figure it out, although I did manage to figure out how to do it via PHP (although I'm not happy with that because it still displays the empty node content instead of nothing all together). Any help would be appreciated.

Comments

ryivhnn’s picture

I am pretty sure both of them have role dependant access, tick boxes to show only that role or leave everything unchecked so everyone can see it.

works at bekandloz | plays at technonaturalist

Juryiel’s picture

Role dependent acces just decides what role can see it no? I want the role of the person being viewed (not the vewer) to determine if something is viewable.

ryivhnn’s picture

If you have a look at the user stuff in views you could probably wrangle a filter or something from it that will show or not show certain things depending on the role/s that user has. I'm theorising as I haven't needed to do anything like what you're doing yet :)

works at bekandloz | plays at technonaturalist

Juryiel’s picture

The filters seem to apply to whoever made the content. In my case, the content is a node I created, and I want it to display only in the profiles of people who have Role1 (regardless of the role the viewer has). My idea of doing this would be through the Arguments, I've done someothing similar with UID arguments, but when I add the view to the APK, the 'User Being Viewed' Context thinggy doesn't have a thing for User Role, just UID and User Name.

ryivhnn’s picture

If you're using Panels to lay things out, the gear has a visibility rules setting where you can have the access permissions based on the currentl logged in user or the user being viewed, that doesn't do what you neede?

works at bekandloz | plays at technonaturalist

Juryiel’s picture

For anyone who may be trying to do the same thing, here is my workaround-ish solution.

In the body of the content you want to display enable php filtering and put something like:

<?php
$userpage = user_load(array('uid' => arg(1))); 

     if (in_array('Role1',$userpage->roles)) {
     
      Content you want displayed goes here (use appropriate PHP like echo or print etc to display it)

     }
    else
    {
    echo "Do Not Show";
    }
?>

Then in your view, go to Filters and set Node:Body != Do Not Show

If anyone knows of a less work-aroundy way to do it let me know, but this seems to work.