News:

Want to get involved in developing SMF? Why not lend a hand on our GitHub!

Main Menu

Only allow user to see custom profile

Started by ninedoors, September 03, 2008, 11:32:57 AM

Previous topic - Next topic

ninedoors

I have created custom profile with custom profile fields such as the users address, city and so on.

What $context array can I use to protect this information so that only the user and admins can view when it when looking at the profile?

Is there a permission already set like that, that I can use?  Somthing like:

<?php

if($context['user']['is_user'] || $context['user']['is_admin']) {

//my code
}

?>
A government big enough to give you everything you want is big enough to take everything you have!

SMF 2.0
BMHL custom theme

SMF community is a great bunch of people!

ccbtimewiz

if( $context['user']['is_logged'] ) { echo 'information'; } would make it so all users that are logged in can see it.

ninedoors

But what I want is for only the user him/her self and admins can see certain info.  Is there someting in place for that already?
A government big enough to give you everything you want is big enough to take everything you have!

SMF 2.0
BMHL custom theme

SMF community is a great bunch of people!

ccbtimewiz

In that case, perhaps try this:

if(( $context['user']['is_owner'] || $context['user']['is_admin'] )) { echo 'stuff'; }

ninedoors

Could I do something like this?

<?php

if ($context['member']['id'] == $context['user']['id'] || $context['user']['is_admin'])
{
//my code
}

?>


Would that work?
A government big enough to give you everything you want is big enough to take everything you have!

SMF 2.0
BMHL custom theme

SMF community is a great bunch of people!

ninedoors

You beat me to it.  Thanks, I'll try that out.
A government big enough to give you everything you want is big enough to take everything you have!

SMF 2.0
BMHL custom theme

SMF community is a great bunch of people!

ninedoors

Worked like a charm.  Thanks ccbtimewiz.

Nick
A government big enough to give you everything you want is big enough to take everything you have!

SMF 2.0
BMHL custom theme

SMF community is a great bunch of people!

Advertisement: