• Resolved buyyes

    (@buyyes)


    I use an Automatic plugin to publish events. They are published, but not displayed. That is, the event is in the list of events and writes that it has been published. But until I go inside the post and click “Update”, it will not be published. It’s like I’m missing some additional field or rule. Can you tell me?

    Video of mistake:
    https://share.vidyard.com/watch/fspzuztXkVraTzBqd6PjEf?

    i try really allot of things from your help pages… I think i try everything, but it doesnt help. Some things that i see in help section:

    Sometimes i see this:
    2024-05-23 15:15:54 No Records over retention limit, skipped pruning expired debug EA Cron
    2024-05-23 15:15:54 No Pending Batch to be started debug EA Cron
    2024-05-23 15:15:54 Filtering records happening after 2024-05-23 08:00:00 debug EA Records
    2024-05-23 15:15:54 No Records Pending, skipped Fetching from service debug EA Cron
    2024-05-23 15:15:54 Filtering records happening after 2024-05-23 08:00:00 debug EA Records
    2024-05-23 15:15:54 No Records Scheduled, skipped creating children debug EA Cron
    2024-05-23 15:14:30 Invalid response code: 401 – during the fetch. debug EA Service

    The page I need help with: [log in to see the link]

Viewing 12 replies - 16 through 27 (of 27 total)
  • Plugin Support Darian

    (@d0153)

    Hi @buyyes

    According to the team, the ORM has a ->save() option for updating data, but there’s?a current bug [BTRIA-2310]. I’ve included your specific use case so we can communicate it to our team.

    We prioritize bugs by taking into consideration the number of users impacted as well as how the bug impacts one’s ability to run an event/sell tickets. I don’t have a specific timeline as to when this issue will be resolved, but trust that our team is aware. Our team communicates updates and bug fixes in our newsletter and via our changelog.

    I’m happy to help if any other questions are coming up around this topic, otherwise I’ll go ahead and close this ticket.

    Thanks again for reporting this issue and for using The Events Calendar! Have a great day.

    Internal Bug Ticket Reference: BTRIA-2310

    Thread Starter buyyes

    (@buyyes)

    @d0153

    Darian, I’ve already explained that I don’t need your help anymore. My mate will post a working solution here as soon as he has time. And, of course, there is nothing you can do to help, we seem to have found out this many times during the dialogue. Exept one thing, I ask you not to close this branch if you really want to help

    Hello @shingen0810 ! @buyyes colleague here. Upon examining the database tables, I found that programmatically created events were being added to the ‘wp_posts’ table, but not to the Event Calendar’s specific tables, ‘wp_tec_events’ and ‘wp_tec_occurrences’. To resolve this, I made a function that manually fills them. The following code is triggered every time a ‘tribe_events’ post is published:

    add_action('publish_tribe_events', 'estrcf_eventFix', 10, 2);

    function estrcf_eventFix ($post_id, $post)
    {
    remove_action('publish_tribe_events', 'estrcf_eventFix', 10);

    if (!wp_is_post_autosave($post_id) && !wp_is_post_revision($post_id)) {
    estrcf_createEvent($post_id);
    }

    add_action('publish_tribe_events', 'estrcf_eventFix', 10, 2);
    }

    function estrcf_createEvent($post_id)
    {
    global $wpdb;
    $wpdb->show_errors();
    $post = get_post($post_id);

    if ($post) {
    $timezone = get_option('timezone_string');
    $date_format = 'Y-m-d H:i:s';
    $start_date = get_post_meta($post->ID, '_EventStartDate', true);
    $end_date = get_post_meta($post->ID, '_EventEndDate', true);
    $start_date_utc = get_gmt_from_date($start_date, $date_format);
    $end_date_utc = get_gmt_from_date($end_date, $date_format);

    $start_datetime = new DateTime($start_date);
    $end_datetime = new DateTime($end_date);
    $interval = $start_datetime->diff($end_datetime);
    $duration = $interval->s + $interval->i * 60 + $interval->h * 3600 + $interval->d * 86400 + $interval->m * 2629746 + $interval->y * 31556952;

    $post_array = array(
    'post_id' => $post->ID,
    'start_date' => $start_date,
    'end_date' => $end_date,
    'start_date_utc' => $start_date_utc,
    'end_date_utc' => $end_date_utc,
    'duration' => $duration,
    'timezone' => $timezone
    );

    $wpdb->insert('wp_tec_events', $post_array);

    array_pop($post_array);

    $query = $wpdb->prepare("SELECT event_id FROM wp_tec_events WHERE post_id = %d", $post_id);
    $post_array['event_id'] = $wpdb->get_var($query);

    $post_array['hash'] = md5($post_array['event_id']. $start_date . $end_date . $timezone);

    echo "<pre>";
    print_r($interval);
    print_r($post_array);
    echo "</pre>";

    $wpdb->insert('wp_tec_occurrences', $post_array);

    } else {
    echo 'Post not found.';
    }
    }

    Note: some automation plugins firstly publish post and then add custom fields or other data to it. You need to make sure that at least _EventStartDate and _EventEndDate are correctly filled in at the time of post recieving the status ‘publish’.

    While the current solution works, it’s not ideal because of:

    $post_array[‘duration’]: The start and end dates are taken from the custom fields ‘_EventStartDate’ and ‘_EventEndDate’ (used by Events Calendar), However, the calculated duration of the event might not be exactly accurate compared to those calculated by the Events Calendar. I believe this may be due to the number of seconds I used to multiply months and years.

    $post_array[‘hash’]: I don’t know how Events Calendar usually calculates hash for events/occurrences so I used event_id, start_date, end_date, and timezone for it. I don’t know whether this may cause problems in the future or not.

    And for deletion of the event you can use something like this:

    add_action('before_delete_post', 'estrcf_deleteEvent', 10, 2);

    function estrcf_deleteEvent($post_id, $post)
    {
    if (!($post->post_type == 'tribe_events')) {
    return;
    }
    global $wpdb;

    $where = array('post_id' => $post_id);
    $result = $wpdb->delete(
    'wp_tec_events',
    $where
    );

    if ($result !== false) {
    echo "The row was deleted from wp_tec_events successfully.";
    } else {
    echo "No row was found in wp_tec_events with the specified post_id value.";
    }

    $result = $wpdb->delete(
    'wp_tec_occurrences',
    $where
    );

    if ($result !== false) {
    echo "The row was deleted from wp_tec_occurrences successfully.";
    } else {
    echo "No row was found in wp_tec_occurrences with the specified post_id value.";
    }
    }

    I hope this was helpful.

    Hi @ynfrea ,

    Thank you so much for sharing this!

    I do understand most of it.

    I will test this ASAP!

    Also, thank you @buyyes too!

    Both are awesome!

    All the best,

    Hi @ynfrea and @buyyes ,

    I just now tested and worked great!

    Thank you!

    All the best,

    Thread Starter buyyes

    (@buyyes)

    Cool cool cool. I think we can close this, Darian.

    @d0153

    Plugin Support Darian

    (@d0153)

    Hi @buyyes @ynfrea

    This is great! Thank you for sharing your workaround. I’ll make sure to share this with the team.

    In the meantime, I’d be closing this thread, and please do not hesitate to bump a new thread on our way. This is for us to track down topics/issues efficiently and for us to follow the WordPress Forum Guidelines.

    Hi @ynfrea @buyyes @d0153 ,

    I am reporting the result which I used the script above.

    == GOOD ==

    By using this script, the auto fetched event posts will be displayed normally (Single post page).

    == ISSUES ==

    1 – With auto fetched event post, the post will NOT display on the event list such as “month” or “list”.

    2 – With “normal publishing event posts”, the post will be displayed “two” on the “list” view.

    It means that the post is only one, but it will display as “there are two posts on the list”.

    === === ===

    I hope you understand what is going on…

    All the best,
    shingen0810

    (@shingen0810)

    Hi @ynfrea , @buyyes and @d0153 ,

    As I have posted the comment above, it is still having a same issue.

    I tried to fix it myself but I was not good enough to do it so.

    If you have any thoughts or idea to fix this, please let me know.

    Thank you for your support in advance.

    All the best,

    Plugin Support Darian

    (@d0153)

    Hi @shingen0810

    The issue was already filed internally through this ticket [BTRIA-2310]. Rest assured, once the fix is out, we will update this thread.

    shingen0810

    (@shingen0810)

    Hi @d0153 ,

    Thank you for your reply.

    I really did not check all actions on TEC properly before posting a comment on here.

    Anyway, I will wait for your team to fix this issue.

    Again, thank you for your great support.

    Plugin Support Darian

    (@d0153)

    Hi @shingen0810

    No worries.

    If you have other questions or concerns, feel free to open a new support thread. This allows us to track topics/issues efficiently and follow the WordPress Forum Guidelines.

Viewing 12 replies - 16 through 27 (of 27 total)
  • You must be logged in to reply to this topic.