Support

Account

Home Forums Front-end Issues Front end update select value

Solved

Front end update select value

  • Hi

    I’m trying to set an employee’s line manager using ACF.

    In the back end it’s all good. I have the field set up and a select option to list of managers. I can assign a line manager in the first instance.

    I’ve created a profile page on the front end for the employee and can display the current line manager using this

    $line_manager = get_field('line_managers', $user_info);

    I can also pull through the line managers select values on the front end profile page using this

    
    $field_name = 'line_managers'; 
    $field = get_field_object($field_name, 'user_'. $user_info->ID);	
    		
    echo '<select name="' . $field['key'] . '">';
      foreach( $field['choices'] as $k => $v )
        {
          echo '<option value="' . $k . '">' . $v . '</option>';
        }
    echo '</select>';
    

    I’m struggling to connect the dots with the next part, which is allowing the employee to change the line manager.

    Any help would be greatly appreciated!

  • you need this: https://www.advancedcustomfields.com/resources/create-a-front-end-form/

    or you could do a custom form which sets the values to your post with update_field( 'line_manager', $picked_value, $post_id );

  • Thanks, Laju.
    Using acf_form worked for me. There was no need to use the <select> parts.

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

You must be logged in to reply to this topic.