Hi
I have a settings page in a plugin comprised of several tabs each with groups of fields on them. When the settings are saved I need to trigger an update to an element in another plugin and for that I used rwmb_after_save_post. This actually worked rather well, but as I added more groups of fields to the settings page i realised that this was getting fired continuously and came to the conclusion that each group of fields on a settings page must be being treated as a separate post which would explain why the element in the other plugin was being continually updated.
Consulting the documentation I realised that using rwmb_{$meta_box_id}_after_save_post might actually be the answer. I went ahead and implemented that but now the element I need to update is not being updated. I suspect that I may have got the signature wrong but I'm not sure.
The meta box I need to trigger the update on saving is defined thus.
add_filter(
'rwmb_meta_boxes',
function ($meta_boxes) {
$prefix = 'vtl_';
$meta_boxes[] = array(
'title' => __('Settings'),
'id' => 'settings',
'settings_pages' => 'vtl_site_options',
'tab' => 'site_colours',
'fields' => array( /* etc
From this I assume that the id I need is 'settings'
In the main constructor of my plugin I have this;
add_action('rwmb_{$settings}_after_save_post', array($this, 'vtl_save_settings'), 20);
and then finally the function itself
public function vtl_save_settings($vtl_site_options)
{ /code here/}
The function that contains the code is not being called so I assume my add action statement is wrong but it looks correct to me.
Could you tell me if there is an obvious error here that I've overlooked , or if not is there another way I can trigger something to happen when just this one particular set of fields is saved from the settings page.
PS. What is the correct format to add code snippets to the forum, I never seem to get it right?
Many thanks