Can I use Additional Fields with Tribe Create Event function

Home Forums Calendar Products Events Calendar PRO Can I use Additional Fields with Tribe Create Event function

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1152025
    Gregory
    Participant

    I’ve defined two Additional Fields: Branch and BookaRoom_ID. I would like to use these fields with the tribe_create_event function. When I view the wp_postmeta table, I see what should be these two fields, but the meta_key values are: _ecp_custom_2 and _ecp_custom_4 (I would have thought that the values would be the Additional Field label names that I defined).
    Anyway, I am now trying to load values to these two fields using tribe_create_event and the meta_input tag (I am running wordpress 4.5.3). The meta_values are not appearing in the wp_postmeta table and I am not able to see them when I use the Filter Bar with those two Additional Fields.
    Code Example:

    #Add Tribe Event
    $startTime = date(‘Y-m-d H:i:s’, $val[‘start’] );
    $ev_startDate = date(‘Y-m-d’, $val[‘start’]);
    $ev_startHour = date(‘H’, $val[‘start’]);
    $ev_startMinute = date(‘i’, $val[‘start’]);
    $endTime = date(‘Y-m-d H:i:s’, $val[‘end’] );
    $ev_endDate = date(‘Y-m-d’, $val[‘end’]);
    $ev_endHour = date(‘H’, $val[‘end’]);
    $ev_endMinute = date(‘i’, $val[‘end’]);

    global $user_ID;
    $new_post = array(
    ‘post_title’ => $_SESSION[‘bookaroom_meetings_externalVals’][‘eventTitle’],
    ‘EventStartDate’ => $ev_startDate,
    ‘EventStartHour’ => $ev_startHour,
    ‘EventStartMinute’ => $ev_startMinute,
    ‘EventEndDate’ => $ev_endDate,
    ‘EventEndHour’ => $ev_endHour,
    ‘EventEndMinute’ => $ev_endMinute,
    ‘post_content’ => $_SESSION[‘bookaroom_meetings_externalVals’][‘eventDesc’],
    ‘post_status’ => ‘publish’,
    ‘post_author’ => $user_ID,
    ‘post_category’ => array(0),
    ‘meta_input’ => array (
    ‘_ecp_custom_4’ => $insertID,
    ‘BookaRoom_ID’ => $insertID,
    ),
    );
    $post_id = tribe_create_event($new_post);

    ###
    When I do this, I can add the value with the meta_key value of BookaRoom_ID but not with the value of _ecp_custom_4. This means that the additional field(s) don’t show in the event view or as a filter value in the filter bar.

    Thanks,
    Gregory

    #1152078
    George
    Participant

    Hey Gregory,

    Thank you for reaching out.

    Just to be clear here early on so that you can set your expectations, we cannot help with custom coding or provide much insights into how to do things with code, etc. Please read this page to learn more about these rules.

    With that in mind, I am not sure why the meta_input parameter isn’t working. This is something worth looking into on our site.

    In the meantime, for your specific needs, I would recommend removing the meta_input parameter and just using the standard update_post_meta() function within WordPress.

    It’s this function that the meta_input parameter calls, anyways, so it should work well for your needs.

    You can learn more about how to use that update_post_meta() function here ? https://codex.wordpress.org/Function_Reference/update_post_meta

    Best of luck with your custom coding!

    — George

    #1152218
    Gregory
    Participant

    That worked. Thanks much for the workaround suggestion.
    Best Regards,
    Gregory

    #1152610
    George
    Participant

    Cheers! 😀

    — George

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Can I use Additional Fields with Tribe Create Event function’ is closed to new replies.