Disable profile viewing -

Permalink 1 user found helpful
I have created a customer area on my side with public profiles where I have set the page to only be shown by the clients group.

Now I want to disable this feature to allow users to see each other's profile, is it possible?

And how do I change the url
www.somenanme.com/profile
on to name
www.somename.com/somename

 
enlil replied on at Permalink Reply
enlil
I've tried to do this in the past and never figured out how i could do it. It would be nice to be able to set permissions on the profile page so users could only see their own profile. But, as is, if you set view permissions to "page owner" only the original admin, or whoever is set to "owner" of the page can see any profiles...
sk01 replied on at Permalink Best Answer Reply
sk01
The first part is quite simple..

to disable the capability of viewing the profile for others, you need to check in single_pages/profile/view.php who's looking. put that code under the define('C5_EXECUTE')

$u = new User();
$userID = $u->uID;
$profileID = $profile->getUserID();


and then you check for whatever you need..
in my example I don't want to have any user be able to look at other profiles:

if($profileID != $userID) {
    $v = View::getInstance();
    $v->setCollectionObject($c);
    /* Render PageForbidden */
    $v->render('/page_forbidden'); // comment me to disable
    /* OR render the Login-Page */
    // Loader::controller('/login'); // uncomment me for the login-page
    // $v->render('/login'); // uncomment me for the login-page
    die();
}


renaming "profile" to something else is a little bit more time-consuming as you need to copy the profile-controller and alter it a bit.
Resonate replied on at Permalink Reply
Thanks, it works!
In fact, it does not matter now that the other user can not see each other.

Thank you so much!
sk01 replied on at Permalink Reply
sk01
you could check for the user group:

$g = Group::getByName("myUserGroup"); 
if($profileID != $userID || !$u->inGroup($g)) {
    $v = View::getInstance();
    $v->setCollectionObject($c);
    /* Render PageForbidden */
    $v->render('/page_forbidden'); // comment me to disable
    /* OR render the Login-Page */
    // Loader::controller('/login'); // uncomment me for the login-page
    // $v->render('/login'); // uncomment me for the login-page
    die();
}