By smilodon on
I customised my profile list as told there http://drupal.org/node/44481
Now i need to insert some lines, that could be seen only by administrator role.
But i cant figure it out. I tryed this http://drupal.org/node/27690 but no help.
The block roletype does not act like this with profile list page...
Instead of showing the content to only admin users, it shows the line for only admin accounts on the profile list.
So if you want declare role, you can use this. Then every admin profile in the list has "Supper Administrator" named near other things...
<?php if (in_array('super administrators',$user->roles)): ?>
<div class="fields">Supper Administraator</div>
<?php endif; ?>
So does anyone know how to show a line on profile list page based on role ???
Comments
try this..
This displays content only to people with administer users permission (this will work in the user_profile.tpl.php page):
This displays content only if the user owns that page. An example might be "there are [n] days left until your membership expires, Click [link] to renew".
This displays content only if the user viewing the page has the correct role. (Where 'super admin' is the role in the example)
Hope that helps
Dub
Currently in Switzerland working as an Application Developer with UBS Investment Bank...using Drupal 7 and lots of swiss chocolate
Thank you...
Thank you...
I was talking about profile_profile.tpl.php, so the 2 firs ones did not work. But the 3rd one works perfectly.
Something about viewing abilityes on profile_profile.tpl.php and user_profile.tpl.php should be added to the "User profile page Snippets" at http://drupal.org/node/35728
try this
insert a
<?php global $user ;?>line at the beginning of the first two snippets and they should work in the profile_profile.tpl.php file as well..Dub
Currently in Switzerland working as an Application Developer with UBS Investment Bank...using Drupal 7 and lots of swiss chocolate
I tryed this one... global
I tryed this one... global thing before the main tag. I tryed to make name feild at profile_profile to display with this method. Found it from the custom block snipplets, but this did not work at all. Somehow i saw my own name for every user account in the list. The by role worked though, because others didnt see this line, but the code between was messed up somehow.
The last option you mentioned workes fine.
One more question about the
One more question about the visibility in the profile list page.
If one looks the page /profile he sees all the users. Eaven the ones who are blocked and not activated. How do i hide blocked user accounts listing in the "/profile" profile list page. ?
If not possible, then it maybe would be possible to make a Status feild... like.. Status: Blocker / Status: Activated. As i saw, the user_profile is disabled, if the user is blocked, but his account still gets listed in the profile list page.
great idea..
Hi Smilodon,
That's a great idea..although I need to give it some thought...I'm not sure using a user role such as "expired membership", "blocked user" or "hide this user" would work. e.g. old posts by those users will still display the username and link to their profile pages...at the same time, that might be useful...all this snippet will do is hide them from the user list page.
I'm busy with something else at the mo..but, try this if you get a chance:
(this uses a checkbox field called
profile_hiddento determine whether to show/hide the profile in the user list. so it goes in your profile_profile.tpl.php file)Step 1 of 2:
Put this at the very top of your profile_profile.tpl.php file:
Step 2 of 2:
Put this at the very bottom of your profile_profile.tpl.php file
I hope that helps..it's actually a handy snippet for offering to users the option of "show these details to anonymous users?" type checkbox.
e.g. if you have a "BUSINESS INFO." category of profile details and another "CURRENT PROJECTS" category, you could use the same snippet to allow users to HIDE their "current projects" profile information from certain users.
I hope that makes sense.
Dub
Currently in Switzerland working as an Application Developer with UBS Investment Bank...using Drupal 7 and lots of swiss chocolate
You mentioned about the role
You mentioned about the role "blocked user". I dont use this, because there is a status checkbox for admins to declare the user status either activated or blocked.
The code does not work somehow...
I get the overall picture about the code, but i tested it. I checked one user status from activated to blocked. Then I edited the profile_profile template file as described. And if i looked at the user list, i saw the same blocked user looking back at me, so he was not hidden.
I think the last line should be. Though this didnt work as well.
<?php else: return; endif; ?>If i changed the 1 to 0 in the first line, then suddenly the whole list was whiped out, and if it i edited it back to 1, then again I saw them all, including the blocked user.
I was all times loged in as admin, if i tested.
just tried it again..
Hi
Just tried it again, in case I made a typo or mistake when copying across to the forum and it works perfectly..
(this uses a checkbox field called
profile_hiddento determine whether to show/hide the profile in the user list. so it goes in your profile_profile.tpl.php file)Step 1 of 2
Put this at the very top of your profile_profile.tpl.php file:
Step 2 of 2
Put this at the very bottom of your profile_profile.tpl.php file
If you're using a user role instead of a custom "profile_hidden" field, you need to check the
$user->rolewhether they are Authenticated or Blocked.Dub
Edit: BTW. Just tried the snippet in Drupal 4.6.3
Currently in Switzerland working as an Application Developer with UBS Investment Bank...using Drupal 7 and lots of swiss chocolate
Nope, same.. not
Nope, same.. not working...
You have something different in oyur system.
This "status blocked" is checed again, and the code used as you said.. the results are still the same as i described before.
When talking about "profile_hidden" do you mean this :
<label class="option"><input type="radio" class="form-radio" name="edit[status]" value="0" checked="checked" /> Blocked</label>This HTML is printed in the admin view of edit user. It displays a radio button, to make a user (not profile, but USER) hidden / unavaliable / unactivated / unauthenticated/ deny access for that user to the website. And this is what i use.But if i go from "user/4/edit" , where i see this checking to to "user/4/edit/otherinfo" (other info as category in a profile), then there is no such button anymore. So i cannot undertand what do you mean by:
"e.g. if you have a "BUSINESS INFO." category of profile details and another "CURRENT PROJECTS" category, you could use the same snippet to allow users to HIDE their "current projects" profile information from certain users."
try this
Hi smilodon..
try this (if you're using Drupal 4.6)
this uses a checkbox field called
profile_hiddento determine whether to show/hide the profile in the user list. so it goes in your profile_profile.tpl.php file)Step 1 of 3!
profile_hiddenStep 2 of 3
Put this at the very top of your profile_profile.tpl.php file:
Step 2 of 2:
Put this at the very bottom of your profile_profile.tpl.php file
Upload your edited profile_profile.tpl.php file to your active theme folder and then go to your user list page.
I hope that makes sense. if you're using 4.7 the override snippet for the user list page needs to be slightly different.
If you want to use a ROLE TYPE to hide/show users you need to change the snippet to check for user roles instead of a profile field.
Dub
Currently in Switzerland working as an Application Developer with UBS Investment Bank...using Drupal 7 and lots of swiss chocolate
Thanx
Oh, now i get you...
This will work i know. Quite original approach.This is really possible to hide users from list like that... but this is not the way i mean it. I mean how the get out the blocked / disabled users from the userlist.
Thanx for the help but... if i would want to use your way, then i would need to check this hidden box for every user i want to hide.
But my site has user activation by admin only. So if a user applies, he becomes disabled / blocked user. But what the hell ?? I can see all disabled / blocked users in the user list page as well. I dont want to see them there before they are activated.
So until admin has not checked new users, then other registred users can see the disabled / blocked users as well.
Now admin goes to check the users and he either deletes or activates them immidiately. So there is no point of this checkbox ... :( If there would be an option "checked by default" then it would work, but i didnt find it in the checkbox creation page.
reverse the snippet value..
Hi Smilodon..
the simplest thing to do would be to reverse the value..i.e. users are automatically NOT HIDDEN until your site admin hides them.
in the snippet above, I have changed the value to "0" (zero), so users are automatically displayed. Your site admin simply checks a "hide this user from the user list" checkbox to hide specific users.
It might be better to use that rather than the "blocked user" technique. As the "blocked user" status might affect the user when trying to do others things on the site. especially if you just want to hide some users from the user list.
I hope that makes sense.
Dub
Currently in Switzerland working as an Application Developer with UBS Investment Bank...using Drupal 7 and lots of swiss chocolate
take the inverse
One solution would be to do the opposite. Change the checkbox from profile_hidden to profile_visible and then simply remove the ! from your conditional statement. It will only show people with the box checked.
You will have to go through and check the box for all your existing users though. And remember to check it when authorizing new users.
A better solution would be to figure out how Drupal is storing the user's active/inactive status. I have never messed with it myself, but there is a "status" attribute to the user object that might be the ticket. I have always seen it set to '1'.
put a:
global $user;
in and then play with the $user->status variable and see what you come up with. It might be as simple to changing the if statement to be ($user->status == 1).
Sorry I can't be more help... Let me know if that variable was it.
-Ben
is this user online or offline..
Hi Ben,
I have put a snippet that checks to see if this user is online or offline? that could be used for that.
i.e. use the online/offline snippet to determine whether to show them in the user list.
Hope that helps. Let me know if you need a hand to modify it specifically for the profile_profile.tpl.php (4.6) or profile_listing.tpl.php (4.7) file.
Dub
Currently in Switzerland working as an Application Developer with UBS Investment Bank...using Drupal 7 and lots of swiss chocolate
No thank you, dont need the
No thank you, dont need the online/offline ...
This would display ONLY online or offline users on the user list... i dont know who really would like this.
It's about blocked/disabled profiles. The reverse idea is very good for that checkbox, but i already have over 100 users, so i need to check all of them manually ?... I know that it is more flexible, as then you can CHOOSE who to show and who not to show, but i really need something simple as bbenone suggested. Just dont know the right php code to insert.
confused..
I already posted the code that does it automatically for you...i.e. automatically SHOW until the site admin chooses otherwise.
http://drupal.org/node/45762#comment-86910
if a custom profile field is not of any use...why not just link it to a role type? i.e. do you have a role type like "pending approval"?
The offline/online link was a direct response to bbenone who was talking about active/inactive users.
Dub
Currently in Switzerland working as an Application Developer with UBS Investment Bank...using Drupal 7 and lots of swiss chocolate
Sorry... i meesed up my
Sorry... i meesed up my point..
Ok here it is now... I am not on the site 24h a day. I need to sleep as well...
So im am off the site... Now there comes 20 guests, they all apply for an account on the web. The profiles are made as disabled and the checkbox is automatically 0. So they are visible on the user list though their accounts are blocked. This is the situatin i want to solve, nothing more, nothing less.
Now if I finally log on the web, then i ... for example... validate 10 of them and delete 10 profiles. I have no reasons to keep some user applications pending. So there is no profiles i need to hide, untill i go offline again.
If it (checkbox) would be 1, then it would be better, but then i would need to check over 100 profiles i have for now to show them in the list...
Hope i expressed myself clearly now. :)
same problem, but worse
Ok now again i need to fix this !!!...
One user used same information in feilds created with profile module... I banned him by e-mail address... i could not bann him by profile feilds... not good.
So i didnt erase the data... i just deactivated both doublicated users and marked them BANNED in front of their original account name.
But now i cannot get rid of them from the user list page... they ARE deactivated, but thei show up.. this is annoing.
Seems i really have to use that checbox süstem somehow... going for the 112 profiles checking...
Hope this issue will be fixed in the new version.
Got it !
Got it !
The code to hide / display by status is actually...
I checked, there really is a status line in the sql database. It is given by the user.module and it is 0 if the user is deactivated. This is a MUST have for this node -> http://drupal.org/node/45873 and maybe this one 2 -> http://drupal.org/node/45774
Damn im happy now !
PS: not for the second node, its usuless there... because the user_profiole is overrided if the user is deactivated by user.module. You just cant see the profile then.
Empty pages returned in the user list results
I added the above code and it worked very well EXCEPT I would get blank pages at the end of a user list that returned multiple pages.
The number of blank pages correlated to the number of blocked users. So, for example, if the user list was 150 users, 75 which were 'blocked', I would get 5 empty pages (if I was displaying 15 profiles per page).
To correct this, I added a patch to my 4.6 profile module similar to the patch found at http://drupal.org/node/44490. So, the following:
was changed to:
Thanks!