mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-17 13:43:38 +09:00
Add filter hooks to populate dropdown options alternative to callback function
This commit is contained in:
@@ -251,13 +251,19 @@ function um_user_edit_profile( $args ) {
|
||||
* Returns dropdown/multi-select options keys from a callback function
|
||||
* @since 2019-05-30
|
||||
*/
|
||||
$has_custom_source = apply_filters("um_has_dropdown_options_source__{$key}", false );
|
||||
|
||||
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' ] ) ) {
|
||||
|
||||
if ( !empty( $array[ 'custom_dropdown_options_source' ] ) && function_exists( $array[ 'custom_dropdown_options_source' ] ) && ! $has_custom_source ) {
|
||||
$options = call_user_func( $array[ 'custom_dropdown_options_source' ], $array[ 'options' ] );
|
||||
if( is_array( $options )){
|
||||
$array[ 'options' ] = array_keys( $options );
|
||||
if( is_array( $options ) ){
|
||||
$array[ 'options' ] = apply_filters("um_custom_dropdown_options__{$key}", array_keys( $options ) );
|
||||
}
|
||||
}else{
|
||||
$array[ 'options' ] = apply_filters("um_custom_dropdown_options__{$key}", array() );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -265,7 +271,7 @@ function um_user_edit_profile( $args ) {
|
||||
$stripslashes = stripslashes( $args['submitted'][ $key ] );
|
||||
if ( in_array( $array['type'], array( 'select' ) ) &&
|
||||
! empty( $array['options'] ) && ! empty( $stripslashes ) &&
|
||||
! in_array( $stripslashes, array_map( 'trim', $array['options'] ) ) ) {
|
||||
! in_array( $stripslashes, array_map( 'trim', $array['options'] ) ) && ! $has_custom_source ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -311,6 +317,7 @@ function um_user_edit_profile( $args ) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( isset( $args['submitted']['description'] ) ) {
|
||||
$to_update['description'] = $args['submitted']['description'];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user