diff --git a/includes/admin/core/class-admin-forms.php b/includes/admin/core/class-admin-forms.php
index 6b6fb523..5daa52c1 100644
--- a/includes/admin/core/class-admin-forms.php
+++ b/includes/admin/core/class-admin-forms.php
@@ -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 ) )
diff --git a/includes/admin/templates/form/profile_customize.php b/includes/admin/templates/form/profile_customize.php
index 6104eae0..b809ffcf 100644
--- a/includes/admin/templates/form/profile_customize.php
+++ b/includes/admin/templates/form/profile_customize.php
@@ -1,10 +1,11 @@
- 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;
+ 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 & 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 & 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',
diff --git a/includes/class-config.php b/includes/class-config.php
index 2e61e1ab..7d92c771 100644
--- a/includes/class-config.php
+++ b/includes/class-config.php
@@ -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',
diff --git a/includes/core/class-shortcodes.php b/includes/core/class-shortcodes.php
index 98c78253..315e3463 100644
--- a/includes/core/class-shortcodes.php
+++ b/includes/core/class-shortcodes.php
@@ -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 '';
+ }
+ }
}
}
}