UM fields display() optimisation suggestion.
-
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 callingfunction 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 insidedisplay() > get_fields()
, then loaded again each timedisplay() > 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.
- The topic ‘UM fields display() optimisation suggestion.’ is closed to new replies.