diff --git a/includes/core/um-actions-profile.php b/includes/core/um-actions-profile.php
index ad3d7cf7..46d71322 100644
--- a/includes/core/um-actions-profile.php
+++ b/includes/core/um-actions-profile.php
@@ -215,8 +215,8 @@ function um_user_edit_profile( $args ) {
*/
do_action( 'um_user_before_updating_profile', $userinfo );
- if ( ! empty( $args['custom_fields'] ) ) {
- $fields = unserialize( $args['custom_fields'] );
+ if ( !empty( $args[ 'custom_fields' ] ) ) {
+ $fields = apply_filters( 'um_user_edit_profile_fields', unserialize( $args[ 'custom_fields' ] ), $args );
}
// loop through fields
@@ -246,6 +246,21 @@ function um_user_edit_profile( $args ) {
}
}
+
+ /**
+ * Returns dropdown/multi-select options keys from a callback function
+ * @since 2019-05-30
+ */
+ if ( isset( $array[ 'options' ] ) && in_array( $array[ 'type' ], array( 'select', 'multiselect' ) ) ) {
+ if ( !empty( $array[ 'custom_dropdown_options_source' ] ) && function_exists( $array[ 'custom_dropdown_options_source' ] ) ) {
+ $options = call_user_func( $array[ 'custom_dropdown_options_source' ], $array[ 'options' ] );
+ if( is_array( $options )){
+ $array[ 'options' ] = array_keys( $options );
+ }
+ }
+ }
+
+
//validation of correct values from options in wp-admin
$stripslashes = stripslashes( $args['submitted'][ $key ] );
if ( in_array( $array['type'], array( 'select' ) ) &&
diff --git a/includes/core/um-filters-fields.php b/includes/core/um-filters-fields.php
index 66c87e88..0089f505 100644
--- a/includes/core/um-filters-fields.php
+++ b/includes/core/um-filters-fields.php
@@ -333,7 +333,7 @@ function um_profile_field_filter_hook__( $value, $data, $type = '' ) {
if ( $data['validate'] == 'vk_url' ) $value = 'https://vk.com/' . $value;
}
-
+
if ( isset( $data['validate'] ) && $data['validate'] == 'skype' ) {
$value = $value;
@@ -351,15 +351,15 @@ function um_profile_field_filter_hook__( $value, $data, $type = '' ) {
}
if ( isset( $data['validate'] ) && $data['validate'] == 'skype' ) {
-
+
$value = str_replace('https://','',$value );
$value = str_replace('http://','',$value );
-
+
$data['url_target'] = ( isset( $data['url_target'] ) ) ? $data['url_target'] : '_blank';
$value = ''.$value.'';
- }
-
+ }
+
if ( !is_array( $value ) ) {
if ( is_email( $value ) )
$value = ''.$value.'';
@@ -681,13 +681,13 @@ function um_profile_field_filter_xss_validation( $value, $data, $type = '' ) {
}
}
} elseif ( 'select' == $type || 'radio' == $type ) {
- if ( ! empty( $data['options'] ) && ! in_array( $value, $data['options'] ) ) {
+ if ( ! empty( $data['options'] ) && ! in_array( $value, $data['options'] ) && empty( $data[ 'custom_dropdown_options_source' ] ) ) {
$value = '';
}
}
- } elseif ( ! empty( $value ) ) {
+ } elseif ( ! empty( $value ) && is_array( $value ) ) {
if ( 'multiselect' == $type || 'checkbox' == $type ) {
- if ( ! empty( $data['options'] ) && is_array( $value ) ) {
+ if ( ! empty( $data['options'] ) && empty( $data[ 'custom_dropdown_options_source' ] ) ) {
$value = array_intersect( $value, $data['options'] );
}
}