Block Appears for Anonymous User
abhisheknagar - April 22, 2009 - 12:36
| Project: | Profile Complete Percent |
| Version: | 6.x-1.2 |
| Component: | User interface |
| Category: | feature request |
| Priority: | minor |
| Assigned: | nrussell |
| Status: | active |
Description
Block can be always set to authenticated user only from block configuration, but its not visible to Anonyamous users by default it would be better can we have a display permission for this block

#1
You have full control of you can and who can not see this module using Drupal's built in block visibility form. This module is intended to be a tool for users to fill out their entire profile, so having anonymous users see the block is pretty pointless as they do not have a profile nor is there any way to generate data for that user.
Please provide more details if this is a feature request.
#2
Hi,
I think the real problem here is that the block displays information of the current login user, so if you are visiting the profile of another user, you will see Profile Complete Percent information for your profile.
I solved the problem adding this snippet in the "Show if the following PHP code returns TRUE" area (for a D5 site):
<?phpglobal $user;
if (arg(0) == 'user' && $user->uid == arg(1)){
return TRUE;
}
else {
return FALSE;
}
?>
(see http://drupal.org/node/134433)
#3
Thank you julien.reulos for your reply to this thread. I am a little concerned about a few things here however. If the feature request is that you can see this block for other users on their profile page instead of seeing your own, this can very well be implemented.
I do want to make note of your code snippet in the example above, and the user you made of the UID 1. The issue here is that you are going to experience the exact same functionality that I've provided, however if you create any other account other than Admin, you will no longer see the block at all. Im not entirely certain what your overall goal was with this snippet, but if the consensus is to provide a means for other viewers to view other profile's percent complete block, I will push this into the next feature release.
Also for all readers, please note that I am not longer supporting new features in 5.x. D6 has been out long enough and 7 is approaching the horizon so keep that in mind D5 users who also need this functionality.
Thanks Everyone!
#4
Reopening thread for some question. Sorry if this is unnecessary...
Uhmm, how? I thought this module does this exactly. I saw the module being used at drupalsn.com and I want to implement it the same way they did.
#5
Personally I don't want that any visitor could see the PCP block of a registered user of my website. I use it only to inform and incite the registered users to complete their own profile. That's the reason why i put that php snippet I was talking about.
I think I should have explain in my first post that I use the PCP block with Panels + Advanced Profile Kit, so the PCP block is only shown at the user profile page (www.example.com/user/[user ID]).
The purpose of
if (arg(0) == 'user' && $user->uid == arg(1))is not to hide the block if the logged in user is not Admin, it's to show the block only for the registered users, with their own percentage completion. You can find a good explanation of the snippet at http://drupal.org/node/134433.Personally I think that the current behaviour of the module is confusing because if a registered user (A) is visiting someone else profile (B), the PCP block keeps indicating the percentage completion for user A, when I think it should indicate the percentage completion for user B.
So I suggest a modification with this patch I submit: the block shows the profile percentage completion of the current logged in user for all the website pages, except when this logged in user is visiting someone else profile, in this case the block shows the percentage completion of this someone else.
I tested it on a D6 website and it works well.
To obtain the behaviour of the block as seen at drupalsn.com, it's necessary to add this URL to the block visibility settings ("Show on only the listed pages"):
/user/*However you will have 2 unsolved problems (with or without patch): the block will keep displaying "0%" for the anonymous users that are visiting the website, and for the logged in users, the sentence "Filling out ... will bring your profile to ... Complete" will be displayed for everyone (I think that it should be visible only for the own logged in user profile).
#6
Sorry I made a mistake: for the 1st problem I mentioned at the end of my previous post, my patch is solving it: when a visitor (anonymous user) is visiting some profiles, he will see the percentage completion of the profile that he is currently seeing.
And to solve the 2nd problem, I updated the patch, so now the sentence "Filling out ... will bring your profile to ... Complete" is only visible if a logged in user is visiting his own profile.
#7
hey guys we misunderstood this what i wanted was if PCP is 100% for user the block should not be shown that's it
julien.reulos thankx ur idea is cool but i dont think, i as a user should be able to view yours PCP