mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-11 18:56:10 +09:00
- fixed profile tab privacy;
- code reviewed;
This commit is contained in:
@@ -118,16 +118,18 @@ if ( ! class_exists( 'um\core\Profile' ) ) {
|
||||
|
||||
// disable private tabs
|
||||
if ( ! is_admin() ) {
|
||||
if( is_user_logged_in() ) {
|
||||
if ( is_user_logged_in() ) {
|
||||
$user_id = um_user('ID');
|
||||
um_fetch_user( get_current_user_id() );
|
||||
}
|
||||
|
||||
foreach ( $tabs as $id => $tab ) {
|
||||
if ( ! $this->can_view_tab( $id ) ) {
|
||||
unset( $tabs[$id] );
|
||||
unset( $tabs[ $id ] );
|
||||
}
|
||||
}
|
||||
if( is_user_logged_in() ) {
|
||||
|
||||
if ( is_user_logged_in() ) {
|
||||
um_fetch_user( $user_id );
|
||||
}
|
||||
}
|
||||
@@ -143,10 +145,13 @@ if ( ! class_exists( 'um\core\Profile' ) ) {
|
||||
*/
|
||||
function tabs_active() {
|
||||
$tabs = $this->tabs();
|
||||
foreach( $tabs as $id => $info ) {
|
||||
if ( ! UM()->options()->get('profile_tab_'.$id) && !isset( $info['_builtin'] ) && !isset( $info['custom'] ) )
|
||||
|
||||
foreach ( $tabs as $id => $info ) {
|
||||
if ( ! UM()->options()->get( 'profile_tab_' . $id ) && ! isset( $info['_builtin'] ) && ! isset( $info['custom'] ) ) {
|
||||
unset( $tabs[ $id ] );
|
||||
}
|
||||
}
|
||||
|
||||
return $tabs;
|
||||
}
|
||||
|
||||
@@ -214,14 +219,14 @@ if ( ! class_exists( 'um\core\Profile' ) ) {
|
||||
function can_view_tab( $tab ) {
|
||||
|
||||
$target_id = UM()->user()->target_id;
|
||||
if( empty($target_id) ) {
|
||||
if ( empty( $target_id ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$can_view = false;
|
||||
|
||||
$privacy = intval( UM()->options()->get( 'profile_tab_' . $tab . '_privacy' ) );
|
||||
switch( $privacy ) {
|
||||
switch ( $privacy ) {
|
||||
case 0:
|
||||
$can_view = true;
|
||||
break;
|
||||
@@ -239,9 +244,11 @@ if ( ! class_exists( 'um\core\Profile' ) ) {
|
||||
break;
|
||||
|
||||
case 4:
|
||||
if( is_user_logged_in() ) {
|
||||
if ( is_user_logged_in() ) {
|
||||
$roles = (array) UM()->options()->get( 'profile_tab_' . $tab . '_roles' );
|
||||
if( in_array( UM()->user()->get_role(), $roles ) ) {
|
||||
|
||||
$current_user_roles = um_user( 'roles' );
|
||||
if ( ! empty( $current_user_roles ) && count( array_intersect( $current_user_roles, $roles ) ) > 0 ) {
|
||||
$can_view = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1277,8 +1277,9 @@ add_action( 'um_after_profile_fields', 'um_add_submit_button_to_profile', 1000 )
|
||||
* @param array $args
|
||||
*/
|
||||
function um_profile_menu( $args ) {
|
||||
if ( ! UM()->options()->get( 'profile_menu' ) )
|
||||
if ( ! UM()->options()->get( 'profile_menu' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// get active tabs
|
||||
$tabs = UM()->profile()->tabs_active();
|
||||
|
||||
Reference in New Issue
Block a user