Custom Fields with tribe_get_events

Home Forums Calendar Products Events Calendar PRO Custom Fields with tribe_get_events

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #26873
    Kyle
    Participant

    I am trying to filter a tribe_get_events query to pull current user events, I stored the user’s id in a custom field but can’t seem to get it to fire right.. hoping someone sees my error…

    global $post, $user;
    get_currentuserinfo();
    $currentid = $current_user->ID;
    $all_events = tribe_get_events(
    array(
    ‘eventDisplay’=>’upcoming’,
    ‘wpcf-xcustomer_id’=>$currentid,
    ));
    foreach($all_events as $post) { stuff..

    It is outputting all upcoming events

    #26892
    Kyle
    Participant

    Of course, forgot to put the custom field in the meta array:

    ‘meta_query’ => array(
    array(
    ‘key’ => ‘wpcf-xcustomer_id’,
    ‘value’ => $currentid ))

    #26899
    Leah
    Member

    Hi Kyle,

    I’m sorry we were not able to get you a substantial reply today. I’m afraid this is above my head and I’ll need assistance from someone with more code experience to give you a thorough answer. We don’t do support over the weekend, but we’ll be back in touch with you asap next week to continue working through this.

    Thank you for your patience.
    ~Leah

    #27003
    Jonah
    Participant

    Hi Kyle,

    Why wouldn’t you just use the author parameter in the query and pass the current user ID into that instead of messing with custom fields?

    global $post, $user;
    get_currentuserinfo();
    $currentid = $current_user->ID;
    $all_events = tribe_get_events(
    array(
    ‘eventDisplay’=>’upcoming’,
    ‘author’=>$currentid,
    ));
    foreach($all_events as $post) {
    stuff..
    }

    Seems like the custom field route is an extra unnecessary step. Does that work?

    – Jonah

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Custom Fields with tribe_get_events’ is closed to new replies.