• Resolved AdrianFx

    (@adrianfx)


    I wanted to dynamical update one of the drop-down fields in the register form and tried using um_shortcode_args_filter filter hook and notice it’s not updating the options, yet the values are correct before and after calling function um_add_register_fields( $args ).

    Then I’ve noticed that I can fix it by using the um_get_form_fields filter hook, but that one is called once for each field in the form and once for display() function.

    When the display() function is called all info is there but not used. Then all fields are reloaded inside display() > get_fields(), then loaded again each time display() > edit_field() > get_field() > get_fields() is called.

    My code:

    
    add_filter( 'um_get_form_fields', 'custom_um_get_form_fields', 100 );
    function custom_um_get_form_fields($args)
    {
    	$newOptions = array('Alt 1', 'Alt 2', 'Alt 3');
    	$args['custom_field_name']['options'] = $newOptions;
    
    	return $args;
    }
    

    I hope this would provide you with enough information to optimise this part.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘UM fields display() optimisation suggestion.’ is closed to new replies.