Skip to main content
Documentation/Developers/APIs/Hooks Reference/Saving
Developers

Saving

After a save

oxygen_after_save_document

Action, $postId. The user clicked Save in the builder and the post was saved. Good for
cache invalidation and audit trails.

add_action('oxygen_after_save_document', function ($postId) {
    // Drop this page from a page cache and record who changed it.
    wp_cache_delete($postId, 'posts');
    update_post_meta($postId, '_last_builder_save', [
        'user' => get_current_user_id(),
        'time' => current_time('mysql'),
    ]);
});

Guarding what a save writes

Four filters run during a builder save, each guarding one class of global data. All default
to true; return false to skip writing that part.

The source marks all four experimental and subject to change or removal. They're worth
knowing about; don't build a product on them.

oxygen_save_global_settings

Filter, true. Guards Global Settings. The other three take the same shape.

function my_only_leads_may_change_globals($allow) {
    return current_user_can('some_custom_capabilitiy') ? $allow : false;
}

add_filter('oxygen_save_global_settings', 'my_only_leads_may_change_globals');
add_filter('oxygen_save_presets', 'my_only_leads_may_change_globals');
add_filter('oxygen_save_selectors', 'my_only_leads_may_change_globals');

oxygen_save_presets

Filter, true. Guards design presets.

oxygen_save_selectors

Filter, true. Guards selectors and classes.

oxygen_save_ai_settings

Filter, true. Guards AI settings.