mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-11 18:56:10 +09:00
- added profile tab privacy 'Owner + Specific roles';
This commit is contained in:
@@ -774,10 +774,20 @@ jQuery(document).ready( function() {
|
||||
if ( input_type === 'checkbox' ) {
|
||||
own_condition = ( value == '1' ) ? cond_field.is(':checked') : ! cond_field.is(':checked');
|
||||
} else {
|
||||
own_condition = ( cond_field.val() == value );
|
||||
if ( Array.isArray( value ) ) {
|
||||
own_condition = ( value.indexOf( cond_field.val() ) !== -1 );
|
||||
} else {
|
||||
own_condition = ( cond_field.val() == value );
|
||||
}
|
||||
}
|
||||
} else if ( tagName === 'select' ) {
|
||||
own_condition = ( cond_field.val() == value );
|
||||
|
||||
if ( Array.isArray( value ) ) {
|
||||
own_condition = ( value.indexOf( cond_field.val() ) !== -1 );
|
||||
} else {
|
||||
own_condition = ( cond_field.val() == value );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( own_condition && parent_condition ) {
|
||||
@@ -794,10 +804,22 @@ jQuery(document).ready( function() {
|
||||
if ( input_type == 'checkbox' ) {
|
||||
own_condition = ( value == '1' ) ? condition_field.is(':checked') : ! condition_field.is(':checked');
|
||||
} else {
|
||||
own_condition = ( condition_field.val() == value );
|
||||
|
||||
if ( Array.isArray( value ) ) {
|
||||
own_condition = ( value.indexOf( condition_field.val() ) !== -1 );
|
||||
} else {
|
||||
own_condition = ( condition_field.val() == value );
|
||||
}
|
||||
|
||||
}
|
||||
} else if ( tagName == 'select' ) {
|
||||
own_condition = ( condition_field.val() == value );
|
||||
|
||||
if ( Array.isArray( value ) ) {
|
||||
own_condition = ( value.indexOf( condition_field.val() ) !== -1 );
|
||||
} else {
|
||||
own_condition = ( condition_field.val() == value );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return ( own_condition && parent_condition );
|
||||
|
||||
@@ -336,7 +336,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
|
||||
'tooltip' => __( 'Select the the user roles allowed to view this tab.', 'ultimate-member' ),
|
||||
'options' => UM()->roles()->get_roles(),
|
||||
'placeholder' => __( 'Choose user roles...', 'ultimate-member' ),
|
||||
'conditional' => array( 'profile_tab_' . $id . '_privacy', '=', 4 ),
|
||||
'conditional' => array( 'profile_tab_' . $id . '_privacy', '=', [ '4', '5' ] ),
|
||||
'size' => 'small'
|
||||
)
|
||||
);
|
||||
|
||||
@@ -101,7 +101,8 @@ if ( ! class_exists( 'um\core\Profile' ) ) {
|
||||
1 => __( 'Guests only', 'ultimate-member' ),
|
||||
2 => __( 'Members only', 'ultimate-member' ),
|
||||
3 => __( 'Only the owner', 'ultimate-member' ),
|
||||
4 => __( 'Specific roles', 'ultimate-member' ),
|
||||
4 => __( 'Only specific roles', 'ultimate-member' ),
|
||||
5 => __( 'Owner and specific roles', 'ultimate-member' ),
|
||||
);
|
||||
|
||||
return $privacy;
|
||||
@@ -227,6 +228,25 @@ if ( ! class_exists( 'um\core\Profile' ) ) {
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
if ( is_user_logged_in() ) {
|
||||
// check profile owner if not - check privacy roles settings
|
||||
$can_view = get_current_user_id() === $target_id;
|
||||
|
||||
if ( ! $can_view ) {
|
||||
if ( isset( $tab_data['default_privacy'] ) ) {
|
||||
$roles = isset( $tab_data['default_privacy_roles'] ) ? $tab_data['default_privacy_roles'] : array();
|
||||
} else {
|
||||
$roles = (array) UM()->options()->get( 'profile_tab_' . $tab . '_roles' );
|
||||
}
|
||||
|
||||
$current_user_roles = um_user( 'roles' );
|
||||
if ( ! empty( $current_user_roles ) && count( array_intersect( $current_user_roles, $roles ) ) > 0 ) {
|
||||
$can_view = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$can_view = true;
|
||||
|
||||
@@ -157,6 +157,9 @@ The plugin works with popular caching plugins by automatically excluding Ultimat
|
||||
|
||||
= 2.1.17: xx, 2021 =
|
||||
|
||||
* Enhancements:
|
||||
- Added: 'Owner and specific roles' privacy type for the Profile tabs
|
||||
|
||||
* Bugfixes:
|
||||
- Fixed: PHP notice when the admin filtering field has the not array default value (e.g. bool)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user