By Allthegearnoidea on
I've been searching for this but can't find a satisfactory answer.
In a users profile there is a "Track" tab. This shows everything the user has added to the site. this is useful for the user who's profile it is, but it seems this is also viewable by any other user too.
Is it possible to make a users track tab only be visible to them and not other users?
If not is it possible to prevent certain content types appearing under the track tab?
Thanks
Comments
You can theme the tab away,
You can theme the tab away, or create a module for it. When I create websites, I usually create a "glue" module just for that site that forces all the modules to behave the way I want by implementing various hooks and overriding theme-able (phptemplate_theme_whatever) functions. That way I don't have to muck with the user-submitted modules much and don't have all the functionality of my site tied to theme.
If you want a quick and dirty fix (that unfortunately ties your site's desired functionality to its selected theme) Add the code below to your theme's template.php file:
Please note: if you already have a function in your template.php file called _phptemplate_variables the you must add the functionality of this function to that one. If you need help with that, paste your template.php file's function here and I'll give ya a hand. Also note that this simply hides the tab. If a user knows the url, he can still see what another user on your site is up to by typing it directly. If you want to change that and don't want to develop a module, here's a quick and dirty fix for that:
at the top of your template.php file add the following:
Brilliant
Thanks for this I have to go off to my real job (the one that pays me) now, but I'll give this a whirl tonight. I'll let you know how I get on.
Thanks
Support for families with children with medical conditions: http://www.parentsown.co.uk
Buy allergen free foods from http://www.freefromforkids.co.uk
Doesn't seem to have done anything
Hi
Thanks for your help. I've added the code but it doesn't seem to have done anything.
Here is my template.php with the code added (the 'Track' (name of the tab) I have changed to 'My Messages' as that is what I changed the name of the tab to in my site):
Any clues as to why it might not be working. As you can see I am clearly no pro. So any help would be great.
Thanks
Support for families with children with medical conditions: http://www.parentsown.co.uk
Buy allergen free foods from http://www.freefromforkids.co.uk
hm... not sure... do you
hm... not sure... do you have a link to your site so I can look more closely at the construction of the tab html?
Sure
www.parentsown.co.uk
Thanks for your help on this.
Meanwhile I'll keep fiddling to see if it's something I'm doing wrong.
Support for families with children with medical conditions: http://www.parentsown.co.uk
Buy allergen free foods from http://www.freefromforkids.co.uk
Wow - not sure how I messed
Wow - not sure how I messed it up like that :-) That's what I get for not testing my code. The following should work. It should remove the "My Messages" tab from any profile you view that isn't your own. Is that what you're trying to do?
Exactly
That's exactly what I'm trying to do :-)
I'll have a go at implementing this tonight....
Nice to see you log in :-) Such a new site I always get excited when new users log in....Even if it was only to look at my code!
Thanks again for sticking with this one! I'll let you know how I get on!
Support for families with children with medical conditions: http://www.parentsown.co.uk
Buy allergen free foods from http://www.freefromforkids.co.uk
Getting there
Thank you for your patience on this cleancutrogue.
The code didn't work i.e. it didn't remove the tab from any profile.
However with some digging back in my old stuff I found some code I implemented ages ago when i was playing with Drupal.
This code removes the tab effectively. But (of course), it removes it for all users regardless of whether you are looking at your profile or someone elses. How would I modify this to get it to show the tab on the logged in users profile but if that logged in user viewed anyone elses profile they would not see that persons My Messages tab?
/**
* Override or insert PHPTemplate variables into the templates.
*/
function _phptemplate_variables($hook, $vars) {
if ($hook == 'page') {
themename_removetab('My Messages', $vars); // replace themename with your theme's name
return $vars;
}
return array();
}
/**
* Removes a tab
*/
function themename_removetab($label, &$vars) { // replace themename with your theme's name
$tabs = explode("\n", $vars['tabs']);
$vars['tabs'] = '';
foreach($tabs as $tab) {
if(strpos($tab, '>' . $label . '<') === FALSE) {
$vars['tabs'] .= $tab . "\n";
}
}
}
?>
Thanks again for all your efforts.
Support for families with children with medical conditions: http://www.parentsown.co.uk
Buy allergen free foods from http://www.freefromforkids.co.uk
the code is nearly the same
the code is nearly the same as mine, but illustrates what I forgot... I forgot to return $vars; from my _phptemplate_variables implementation. In fact, my first solution would have worked if I would have remembered to return $vars;... so just add the return at the end of the function and all should work.
In other words:
Confirmation that...
...you are a total genius!! Works like a dream! My Messages tab is visible to the logged in user but not to any user who is viewing another users profile.
Thank you so much for sticking with me on this one cleancutrogue. You really do the community justice. :-)
Thanks again.
Support for families with children with medical conditions: http://www.parentsown.co.uk
Buy allergen free foods from http://www.freefromforkids.co.uk
Glad to help...
I'm just sorry I forgot to return the variable! :-) Have fun!
I'm trying to do the same
I also need to hide the Track tab for all users except the current user. The reason is there seems to be no other way to show comments for a user. I've tried all kinds of view arguements and settings and also attempted to config nodecomment module which is not what I needed. So Track tab works for my purpose. However, since I have permissions so all users are able to view other users profiles, an users Track tab is also viewable by all users.
I'm using Zen and when attempting to add code to template.php it seems to not work. The page still renders but shows warning on screen. The tab is still viewable by all users.
Warning: Call-time pass-by-reference has been deprecated in C:\wamp\www\sites\all\themes\testsite\template.php on line 181
using...
Is the code working for D6?
Is the code working for D6?
subscribing
subscribing
Or you could add permissions to the module
you can find a patch to add permissions at:
http://drupal.org/node/762962
I don't like any site where I don't have admin menu
Views modules
Another way to do that is with Views modules. Read more at http://drupal.org/node/230632#comment-759623