I am trying to hide tab for user page. This is good script but work only for node type. How can I make it work for user pages? Thanks to all!
function bartik_preprocess_page(&$variables, $hook) {
if (!empty($variables['node']) && $variables['node']->type == 'article' && in_array('editor', $variables['user']-> roles)) {
$to_be_removed = array('node/%/edit', 'node/%/view');
foreach ($variables['tabs'] as $group_key =>$tab_group) {
if (is_array($tab_group)) {
foreach ($tab_group as $key =>$tab) {
if (isset($tab['#link']['path']) && in_array($tab['#link']['path'], $to_be_removed)) {
unset($variables['tabs'][$group_key][$key]);
}
}
}
}
}
}
/-------- Update --------/
Now I tryed this:
function my_theme_preprocess_page(&$variables, $hook) {
/* Hide Tabs in users page */
global $user;
$arg = arg();
if (($arg == 'user') && in_array('gestore', $variables['user']->roles)) {
foreach ($variables['tabs'] as $group_key =>$tab_group) {
if (is_array($tab_group)) {
foreach ($tab_group as $key =>$tab) {
if (isset($tab['#link']['path'])) {
unset($variables['tabs'][$group_key][$key]);
}
}
}
}
}
}
But not work.
/----- Last Update -------/
This works. Thx @Yogesh.
global $user;
if ((arg(0) == 'user') && in_array('editor', $variables['user']->roles)) {
foreach ($variables['tabs'] as $group_key =>$tab_group) {
if (is_array($tab_group)) {
foreach ($tab_group as $key =>$tab) {
if (isset($tab['#link']['path'])) {
unset($variables['tabs'][$group_key][$key]);
}
}
}
}
}
$arg
wrong,$arg
is an array. You've to check$arg[0] == 'user'
when checking first argument as user.