- roles multiselect on Profile form settings;

This commit is contained in:
nikitozzzzzzz
2018-06-03 20:02:55 +03:00
parent 9fa2964281
commit abb00b74c3
4 changed files with 30 additions and 18 deletions
+1 -1
View File
@@ -731,7 +731,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) {
$value = $this->get_field_value( $field_data );
$options = '';
foreach ( $field_data['options'] as $key=>$option ) {
foreach ( $field_data['options'] as $key => $option ) {
if ( ! empty( $field_data['multi'] ) ) {
if ( ! is_array( $value ) || empty( $value ) )
@@ -1,10 +1,11 @@
<div class="um-admin-metabox">
<?php
foreach ( UM()->roles()->get_roles( __( 'All roles', 'ultimate-member' ) ) as $key => $value ) {
$_um_profile_role = UM()->query()->get_meta_value( '_um_profile_role', $key );
if ( ! empty( $_um_profile_role ) )
$profile_role = $_um_profile_role;
<?php $profile_role_array = array();
foreach ( UM()->roles()->get_roles() as $key => $value ) {
$_um_profile_role = UM()->query()->get_meta_value( '_um_profile_role', $key );
if ( ! empty( $_um_profile_role ) ) {
$profile_role_array[] = $_um_profile_role;
}
}
UM()->admin_forms( array(
@@ -14,8 +15,8 @@
array(
'id' => '_um_profile_use_custom_settings',
'type' => 'select',
'label' => __( 'Apply custom settings to this form', 'ultimate-member' ),
'tooltip' => __( 'Switch to yes if you want to customize this form settings, styling &amp; appearance', 'ultimate-member' ),
'label' => __( 'Apply custom settings to this form', 'ultimate-member' ),
'tooltip' => __( 'Switch to yes if you want to customize this form settings, styling &amp; appearance', 'ultimate-member' ),
'value' => UM()->query()->get_meta_value( '_um_profile_use_custom_settings', null, 0 ),
'options' => array(
0 => __( 'No', 'ultimate-member' ),
@@ -23,13 +24,14 @@
),
),
array(
'id' => '_um_profile_role',
'type' => 'select',
'label' => __( 'Make this profile form role-specific', 'ultimate-member' ),
'tooltip' => __( 'Please note if you make a profile form specific to a role then you must make sure that every other role is assigned a profile form', 'ultimate-member' ),
'value' => ! empty( $profile_role ) ? $profile_role : 0,
'options' => UM()->roles()->get_roles( __( 'All roles', 'ultimate-member' ) ),
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 )
'id' => '_um_profile_role',
'type' => 'select',
'multi' => true,
'label' => __( 'Make this profile form role-specific', 'ultimate-member' ),
'tooltip' => __( 'Please note if you make a profile form specific to a role then you must make sure that every other role is assigned a profile form', 'ultimate-member' ),
'value' => $profile_role_array,
'options' => UM()->roles()->get_roles(),
'conditional' => array( '_um_profile_use_custom_settings', '=', 1 )
),
array(
'id' => '_um_profile_template',
+1 -1
View File
@@ -210,7 +210,7 @@ if ( ! class_exists( 'um\Config' ) ) {
'_um_profile_header_menu' => 'bc',
'_um_profile_empty_text' => 1,
'_um_profile_empty_text_emo' => 1,
'_um_profile_role' => '0',
'_um_profile_role' => array(),
'_um_profile_template' => 'profile',
'_um_profile_max_width' => '1000px',
'_um_profile_area_max_width' => '600px',
+12 -2
View File
@@ -522,8 +522,18 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) {
$use_custom = get_post_meta( $this->form_id, "_um_{$mode}_use_custom_settings", true );
if ( $use_custom ) { // Custom Form settings
$current_user_roles = UM()->roles()->get_all_user_roles( um_profile_id() );
if ( ! empty( $args['role'] ) && ! in_array( $args['role'], $current_user_roles ) ) {
return '';
//backward compatibility between single/multi role form's setting
if ( ! empty( $args['role'] ) ) {
if ( is_array( $args['role'] ) ) {
if ( ! count( array_intersect( $args['role'], $current_user_roles ) ) ) {
return '';
}
} else {
if ( ! in_array( $args['role'], $current_user_roles ) ) {
return '';
}
}
}
}
}