Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gianghl1983/b2140e75ae8010661ed39237b278d4dd to your computer and use it in GitHub Desktop.
Save gianghl1983/b2140e75ae8010661ed39237b278d4dd to your computer and use it in GitHub Desktop.
<?php
add_filter('um_profile_tabs', 'pages_tab', 1000 );
function pages_tab( $tabs ) {
$user_id = um_get_requested_user();
// Show to profile owners only
if ( is_user_logged_in() && get_current_user_id() == $user_id ) {
$tabs['faves'] = array(
'name' => 'Faves',
'icon' => 'fa fa-star',
'custom' => true
);
}
// Show to other profiles
if ( is_user_logged_in() && get_current_user_id() != $user_id ) {
$tabs['faves'] = array(
'name' => 'Faves',
'icon' => 'fa fa-star',
'custom' => true
);
}
// Show to everyone
$tabs['faves'] = array(
'name' => 'Faves',
'icon' => 'fa fa-star',
'custom' => true
);
// Hide from specific roles
$hide_from_roles = array( 'teacher','principal' );
if ( is_user_logged_in() && ! in_array( um_user('role') , $hide_from_roles ) ) {
$tabs['faves'] = array(
'name' => 'Faves',
'icon' => 'fa fa-star',
'custom' => true
);
}
return $tabs;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment