How would I show user info in private profile?

Permalink
I am using public profiles as a sort of client area. What I want to do is have a link that shows loads up the users info that they fill out when they sign up.

Right now in order to see that info I have to sign in as the user and click edit which isnt a great way to do it because I could accidentally delete some info. I want administrators to just be able to go to the users profile, click the "view info" link and see all the info similar to clicking edit but without being able to edit the info.

Thanks in advance guys!

 
adajad replied on at Permalink Reply
adajad
You can do this in many ways, but one of them is by modifying the profile single page to show all attributes if the logged in user is either in the 'Administrators' group or is the SuperUser.

Override the single page by copying 'public_html/concrete/single_pages/profile/view.php' to 'public_html/single_pages/profile/view.php' (create folders where necessary).

Edit your newly created view.php file to read like below:
<?php  defined('C5_EXECUTE') or die("Access Denied."); ?>
<div id="ccm-profile-wrapper">
    <?php  Loader::element('profile/sidebar', array('profile'=> $profile)); ?>    
    <div id="ccm-profile-body">   
        <div id="ccm-profile-body-attributes">
        <div class="ccm-profile-body-item">
        <h1><?php echo $profile->getUserName()?></h1>
        <?php 
        $u = new User(); //the current logged in user
        $g = Group::getByName('Administrators'); //get the 'Administrators' group object
        $uaks = UserAttributeKey::getPublicProfileList();
        if ($u->inGroup($g) || $u->isSuperUser()) { //if logged in user is in group Administrators or is SuperUser (= user 1) show all attributes
            foreach($uaks as $ua) { ?>
                <div>
                    <label><?php echo $ua->getKeyName()?>:</label>


You also need to edit the attributes themselves to be displayed in public profile.

Doing it this way will list all attributes for the users in the Administrators group when the Administrator is visiting a profile page. This override will not let anyone else see this information, but the users can still edit their information by clicking on the Edit link.
merge replied on at Permalink Reply
Thanks for answering!! I tried out your solution but I didn't notice any difference when I applied the code and the custom view other than my pages styling wasn't applied but that's an easy fix.

I knew about making the attributes visible in the users profile but I didnt want them to display. Maybe I am misunderstanding something as I am a newb at php so maybe I put it in wrong.

I appreciate your help very much!
merge replied on at Permalink Reply
Also I forgot to add I tried just pasting in the code along with what was there and also using it on its own and I didnt notice anything either way. I will continue to tinker though.
merge replied on at Permalink Reply
I cleared the cache and now I get this error:

Parse error: syntax error, unexpected $end in /home/...../single_pages/profile/view.php on line 15
adajad replied on at Permalink Reply
adajad
You need to set the attributes as visible in profile for my code to work. In my code, only 'Administrators' and 'SuperUser' will see the attributes in the profile pages since I wrapped the whole attribute output in an if statement with the condition that the user needs to be in the 'Administrator' group or the 'SuperUser' to the the output.

Try it again and let me know.

I didn't get any warning or error on line 15 when I tested the code before posting here.
merge replied on at Permalink Reply
Thanks for continuing on with me. I retried and I get the same error. I literally just pasted in the code you gave me and uploaded it. I tried to attach the view.php file but I wasn't allowed to.

I have all 20+ attributes set to show in profile.
adajad replied on at Permalink Reply
adajad
I can take a look if you are willing to let me into your system (both via web and ftp). If so, just send me a pm with login information.
merge replied on at Permalink Reply
Thanks. That is very kind but it is a client site so I cant. Thanks for trying to help me anyway. You rock!
adajad replied on at Permalink Reply
adajad
I can't let this go...

Did you follow my instructions to the point?

1. Copy 'public_html/concrete/single_pages/profile/view.php' to 'public_html/single_pages/profile/view.php'.
2. Edit the newly created view.php to match my code above (make sure you view the entire code block).
3. Edit your user attributes to be displayed in profile.
4. Clear your site and browser cache.
5. Test by viewing a profile page as Guest, Registered User and Administrator (only Administrator should see the details).
misebaz replied on at Permalink Reply
misebaz
Hi Adajad,

Will what you provided above enable a user to see their own profile and keep private from other users?

What I am looking to do is have a user submit an application form which they will be able to view what they submitted anytime they wanted and no else.

Thanks

Barry
adajad replied on at Permalink Reply
adajad
What I supplied above will still let other users to see all members profile pages, but not the attributes associated with the profile.