Support

Account

Home Forums General Issues Two user fields into one

Helping

Two user fields into one

  • I have some user fields on posts where users can be selected, I would like to take those fields and combine them into another field. So basically the users in field 1 and field 2 show up in field 3. Here is what I have tried so far. The return format is user array. The result in the third field should be the same selections that are in the other two fields. The included photo should help show what I am looking for.
    `add_action( ‘acf/save_post’,
    ‘my_acf_save_post’, 10 );
    function my_acf_save_post( $post_id ) {
    // Get value of field 1
    $value1 = get_field( ‘contractor’,$post_id );
    // Get value of field 2
    $value2 = get_field( ‘architect’, $post_id );

    update_field( ‘project_user_select’, $value1 . $value2, $post_id );
    }’

  • Here is the code I have tried entered correctly.

    add_action( 'acf/save_post',  
    'my_acf_save_post', 10 );
    function my_acf_save_post( $post_id ) {
    // Get value of field 1
    $value1 = get_field( 'pds_project_manager',$post_id );
     // Get value of field 2 
    $value2 = get_field( 'architect', $post_id );
    
    update_field( 'project_user_email_select', $value1 . $value2, $post_id );
    }
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.