mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-17 21:53:43 +09:00
the issue with the options from custom callback function for multi-select/select type field (Telegram, May 30)
This commit is contained in:
@@ -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' ) ) &&
|
||||
|
||||
@@ -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 = '<a href="'. 'skype:'.$value.'?chat'.'" title="'.$value.'" target="'.$data['url_target'].'" ' . $url_rel . '>'.$value.'</a>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( !is_array( $value ) ) {
|
||||
if ( is_email( $value ) )
|
||||
$value = '<a href="mailto:'. $value.'" title="'.$value.'">'.$value.'</a>';
|
||||
@@ -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'] );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user