action rwmb_after_{$meta_box_id} or action for settings page

Support General action rwmb_after_{$meta_box_id} or action for settings page

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #10250
    Jason KinneyJason Kinney
    Participant

    I have a settings page with 9 meta boxes and I need to fire some code after the settings page is saved.

    It looks like as of right now the only hook I can use is rwmb_after_{$meta_box_id}. Do I need to do an add_action 9 times or do you have a hook that will fire when a settings page is saved, like the WordPress action wp_insert_post?

    If you don't, it would be nice and more efficient to trigger one action when all meta boxes in a page is saved.

    #10251
    Jason KinneyJason Kinney
    Participant

    Sorry I meant rwmb_{$meta_box_id}_after_save_post . . . instead of a meta box ID, a $settings_pages[id] as opposed to the meta_boxes[id].

    fyi, there is a space in the action of "rwmb_{$meta_box_id}_ after_save_post."

    #10277
    Anh TranAnh Tran
    Keymaster

    Yes, you can do that with the hook mb_settings_page_load. It's the internal hook used to save the fields' values after the settings page is loaded. The process uses priority 10, so if you want to do something after that, you should use a higher priority, such as 20.

    Here is an example:

    add_action( 'mb_settings_page_load', function ( $args ) {
        if ( $args['id'] === 'YOUR SETTINGS PAGE ID' ) {
            // Do something
        }
    }, 20 );
    #10284
    Jason KinneyJason Kinney
    Participant

    Perfect, tks!.

    Is that listed hook listed in the docs?

    #10288
    Anh TranAnh Tran
    Keymaster

    No, it's created for internal use. I'll add it to the docs right now.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.