News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Show Profile Summary Only To Buddy

Started by Hj Ahmad Rasyid Hj Ismail, August 04, 2011, 01:20:19 AM

Previous topic - Next topic

Hj Ahmad Rasyid Hj Ismail

Hiya all again,

Today, in response to a coding discussion, I am going to share with another simple tip or trick on how to show profile summary only to buddy(ies) in profile page of your forum. Of course this would not limit the profile owner and admin to access the profile summary page. In fact, using the given code, you can also use it to hide certain contents and show them only to the profile owner buddy(ies) only.

To show the whole profile summary only to buddy(ies), open your forum Profile.template.php:
1. Find:
function template_summary()
{
global $context, $settings, $options, $scripturl, $modSettings, $txt;

Change to:
function template_summary()
{
global $context, $settings, $options, $scripturl, $modSettings, $txt;

if ($context['member']['is_buddy'] || $context['user']['is_owner'] || $context['user']['is_admin'])
{
    echo '<div>';
}



2. And find:
}

// Template for showing all the posts of the user, in chronological order.

Change to:
echo ' </div>';
}

}

// Template for showing all the posts of the user, in chronological order.



And to show certain content only to buddy(ies), just follow this sample:
if ($context['member']['is_buddy'] || $context['user']['is_owner'] || $context['user']['is_admin'])
{
   echo '<div>example content</div>';
}


And that should do the trick in your forum profile page. Happy testing. I hope you all will like it.

Ricky.


Hj Ahmad Rasyid Hj Ismail


Advertisement: