mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-06-05 15:09:37 +09:00
Merge branch 'fix/can_view_tab' of https://github.com/ultimatemember/ultimatemember into release/2.0.18
This commit is contained in:
@@ -212,28 +212,36 @@ if ( ! class_exists( 'um\core\Profile' ) ) {
|
||||
* @return bool
|
||||
*/
|
||||
function can_view_tab( $tab ) {
|
||||
$privacy = intval( UM()->options()->get( 'profile_tab_' . $tab . '_privacy' ) );
|
||||
|
||||
$target_id = UM()->user()->target_id;
|
||||
if( empty($target_id) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$can_view = false;
|
||||
|
||||
$privacy = intval( UM()->options()->get( 'profile_tab_' . $tab . '_privacy' ) );
|
||||
switch( $privacy ) {
|
||||
case 0:
|
||||
$can_view = true;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
$can_view = is_user_logged_in() ? false : true;
|
||||
$can_view = ! is_user_logged_in();
|
||||
break;
|
||||
|
||||
case 2:
|
||||
$can_view = is_user_logged_in() ? true : false;
|
||||
$can_view = is_user_logged_in();
|
||||
break;
|
||||
|
||||
case 3:
|
||||
$can_view = get_current_user_id() == um_user( 'ID' ) ? true : false;
|
||||
$can_view = is_user_logged_in() && get_current_user_id() === $target_id;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
$can_view = false;
|
||||
if( is_user_logged_in() ) {
|
||||
$roles = UM()->options()->get( 'profile_tab_' . $tab . '_roles' );
|
||||
if( is_array( $roles )
|
||||
&& in_array( UM()->user()->get_role(), $roles ) ) {
|
||||
$roles = (array) UM()->options()->get( 'profile_tab_' . $tab . '_roles' );
|
||||
if( in_array( UM()->user()->get_role(), $roles ) ) {
|
||||
$can_view = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user