Description
Fires after publishing a save on an options page.
This action allows you to hook in after an options page has been saved in the admin.
Parameters
do_action( 'acf/options_page/save', $post_id, $menu_slug );
$post_id
(int|string) The ID of the page being edited.$menu_slug
(string) The current options page menu slug.
The $post_id
defaults to ‘options’, but can be set as a post or a user ID when registering the options page.
Changelog
- Added in version 6.1.7
Example
add_action('acf/options_page/save', 'my_acf_save_options_page', 10, 2);
function my_acf_save_options_page( $post_id, $menu_slug ) {
if ( 'theme-settings' !== $menu_slug ) {
return;
}
// Get newly saved values for the theme settings page.
$values = get_fields( $post_id );
// Check the new value of a specific field.
$analytics_code = get_field('analytics_code', $post_id);
if( $analytics_code ) {
// Do something...
}
}
Supercharge Your Website With Premium Features Using ACF PRO
Speed up your workflow and unlock features to better develop websites using ACF Blocks and Options Pages, with the Flexible Content, Repeater, Clone, Gallery Fields & More.