Show content from different groups to other groups
Permalink 2 users found helpful
Little hard to explain but what I mean is the following:
I've 2 user groups
A
and
B
if some user from group A checks out a profile from group B he needs to see different content (blocks) then from his own.
What I have now is:
But that is checking for the current logged in user. Can this be changed to the current profile you're watching ?
I've 2 user groups
A
and
B
if some user from group A checks out a profile from group B he needs to see different content (blocks) then from his own.
What I have now is:
But that is checking for the current logged in user. Can this be changed to the current profile you're watching ?
no one has any idea how this should be done ?
The profile page (ie, the view in /single_pages/profile) gets passed a variable representing the user that the profile is for. It's something like $user.
You can figure it out pretty easily by looking at the controller. Or by just dumping out all variables that are available and sorting through those. (Something like var_dump(get_defined_vars()); );
You can figure it out pretty easily by looking at the controller. Or by just dumping out all variables that are available and sorting through those. (Something like var_dump(get_defined_vars()); );
Not really a native english speaker and I think you mis understood me (sorry for my english in this case ;) )
What I now have in view.php (/single_pages/profile/view.php) is this:
this is used for some thinks on the profile page that is working great. However I have 2 different user groups with 2 different profile pages. So I created the following:
(check the main post for the other code)
This ($u->inGroup) is only checking for the user that is logged in (for example I'm a user that is logged in and I belong in group A). As I view my profile I get to see this block. So that is working just fine.
BUT when I want to view a group B profile (as a group A user) I get to see a group A profile on a group B profile.
Does it makes sense?
To get it clear:
User 1 in group A sees his own profile (that is working)
User 1 in Group A checksout User 2 in Group B - but he sees his own profile layout (not the b layout because the user viewing is from group A)
What I now have in view.php (/single_pages/profile/view.php) is this:
$u = new User(); $ui = UserInfo::getByID($u->getUserID());
this is used for some thinks on the profile page that is working great. However I have 2 different user groups with 2 different profile pages. So I created the following:
$grp = Group::getByName('A'); if($u->inGroup($grp)) { echo 'do stuff here'; }
(check the main post for the other code)
This ($u->inGroup) is only checking for the user that is logged in (for example I'm a user that is logged in and I belong in group A). As I view my profile I get to see this block. So that is working just fine.
BUT when I want to view a group B profile (as a group A user) I get to see a group A profile on a group B profile.
Does it makes sense?
To get it clear:
User 1 in group A sees his own profile (that is working)
User 1 in Group A checksout User 2 in Group B - but he sees his own profile layout (not the b layout because the user viewing is from group A)
Yes. I understand.
Basically, you need $u to be "the user that the profile 'belongs' to". So you can call
So of course that user is going to be available. How else would the various attributes (name, avatar image, etc) get printed out? So just take a look at what variable that is. (I think it's $profile or something.)
Basically, you need $u to be "the user that the profile 'belongs' to". So you can call
if ($userThatThisProfilePageBelongsToIsUser2ButNotUser1WhichImLoggedInAs->inGroup($grp)) {
So of course that user is going to be available. How else would the various attributes (name, avatar image, etc) get printed out? So just take a look at what variable that is. (I think it's $profile or something.)
Thanks alot for helping! I will reply back when I found something :)
And after looking at it for some min I got it, thanks again!
What the problem was, in the profile page (single_page) the userid is checked with this:
Now just simply do the samething, except change $u to $profile (since we want the profile that is getting viewed)
What the problem was, in the profile page (single_page) the userid is checked with this:
$ui = UserInfo::getByID($u->getUserID());
Now just simply do the samething, except change $u to $profile (since we want the profile that is getting viewed)
Great solution, I was trying to do this too :-)