Support

Account

Home Forums General Issues get acf field values from user profile and pass to create post form Reply To: get acf field values from user profile and pass to create post form

  • $post_data = array(
    ‘post_title’ => ‘new post’,
    ‘post_type’ => ‘proposal_entries’,
    ‘post_status’ => ‘publish’
    );
    $post_id = wp_insert_post( $post_data );
    $ids = get_field(‘client’);
    $user_info = get_userdata($ids);
    $company = get_field(‘company_name’, ‘user_’. $ids);
    $number = get_field(‘contact_number’, ‘user_’. $ids );
    // Save a value for company
    $field_key = “field_601776e86bca8”;
    $value = $company ;
    update_field( $field_key, $value, $post_id );

    // Save a value for number
    $field_key = “field_60e307cb6c6f1z”;
    $value = $number;
    update_field( $field_key, $value, $post_id );

    update_field( $field_key, $value, $post_id );`