Replies: 0
https://docs.ultimatemember.com/article/64-extending-ultimate-member-profile-menu-using-hooks
// You could set the default privacy for custom tab and disable to change the tab privacy settings in admin menu.
/*
* There are values for 'default_privacy' atribute
* 0 - Anyone,
* 1 - Guests only,
* 2 - Members only,
* 3 - Only the owner
*/
// Filter
function um_mycustomtab_add_tab( $tabs ) {
$tabs['mycustomtab'] = array(
'name' => 'My Custom',
'icon' => 'um-faicon-pencil',
'default_privacy' => 3,
);
return $tabs;
}
add_filter( 'um_profile_tabs', 'um_mycustomtab_add_tab', 1000 );
/**
* Check an ability to view tab
*
* @param $tabs
*
* @return mixed
*/
function um_mycustomtab_add_tab_visibility( $tabs ) {
if ( empty( $tabs['mycustomtab'] ) ) {
return $tabs;
}
$user_id = um_profile_id();
if ( ! user_can( $user_id, 'read' ) ) {
unset( $tabs['mycustomtab'] );
}
return $tabs;
}
add_filter( 'um_user_profile_tabs', 'um_mycustomtab_add_tab_visibility', 2000, 1 );
// Action
function um_profile_content_mycustomtab_default( $args ) {
echo 'Hello world!';
}
add_action( 'um_profile_content_mycustomtab_default', 'um_profile_content_mycustomtab_default' );