Support

Account

Home Forums Front-end Issues Front-end form doesnt populate 'value' field anymore

Solved

Front-end form doesnt populate 'value' field anymore

  • I am using ACF to allow logged-in users to use a front-end version of the back-end form.

    The ‘value’ fields used to load on the front end just fine but now they do not as of Jan 18, 2016.

    I’m using acf load_value to modify the value into a dynamic value, but the code cannot even reach the default value to begin with anymore.

    I can still see the value in my back-end forms just not my front-end.

    Was something changed recently?

    Here is my current modification code:

    function my_acf_load_value_title( $value, $post_id, $field ) {
        if ( $value = 'Default title' ) {
           
            $value = 'test';
          
        }
    
        return $value;
    
    }
    
    add_filter( 'acf/load_value/key=field_xxx', 'my_acf_load_value_title', 10, 3 ); 

    I am using this within my post_form code to modify the value on the page when it loads and then the form submits the field ‘readonly’ with the value I set for the user.

    Any ideas?

  • Still not sure why the values aren’t loading but I solved the issue.

    I was also, in conjunction with the code snippet above using the following ‘prepare_field’ hooks:

    function my_acf_prepare( $field ) {
        
    /* this was added to fix above */
        $field['value'] = htmlspecialchars($_GET["xxx"]);
    
    /* this was always here */
        $field['readonly'] = true;
    
        return $field;
        
    }
    
    add_filter('acf/prepare_field/name=zzz', 'my_acf_prepare');

    I just added a ‘value’ $field object into the prepare field code above that just assigns a value to the field during the prepare_field action instead of using ‘load_value’ from above in cojunction with the ‘prepare_field’ hook.

    Hope this helps someone else.

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Front-end form doesnt populate 'value' field anymore’ is closed to new replies.