• Resolved mc-landin

    (@mc-landin)


    I’m trying to add a custom meta box to the events, as to add an image gallery to events. I’ve build plenty of boxes, and things work fine, except for the saving function, as data from the custom meta box is not actually saved.

    Does the event calendar block custom fields to be added?
    The save function is the following;

    function tribe_events_save_meta_boxes_data($post_id)
    {
        if (!isset($_POST['tribe_events_meta_box_nonce']) || !wp_verify_nonce($_POST['tribe_events_meta_box_nonce'], basename(__FILE__))) {
            return;
        }
        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
            return;
        }
        // Check the user's permissions.
        if (!current_user_can('edit_post', $post_id)) {
            return;
        }
        if (isset($_POST['space_images'])) {
            update_post_meta($post_id, 'space_images', $_POST['space_images']);
        } else {
            delete_post_meta($post_id, 'space_images');
        }
    }
    add_action('save_post_tribe_events', 'tribe_events_save_meta_boxes_data', 10, 2);
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter mc-landin

    (@mc-landin)

    Update, the meta_box_nonce is causing an issue, not yet resolved.

    Plugin Author Gustavo Bordoni

    (@bordoni)

    Hi @mc-landin,

    You should be able to use tribe_events_event_save to hook into the saving process.

    Just make sure you have proper checks like you are doing there and you shouldn’t need to do the nonce, since that will be done for you by us on our side of the code.

    Best regards,

    best regards,

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘add_action(‘save_post’) blocked?’ is closed to new replies.