Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I need to run some code after a new item has been inserted into a WordPress nav menu.

Is there any hook on menu modification or something similar?

share|improve this question
    
The question is not clear. –  s_ha_dum Jun 15 at 1:45
    
I removed some irrelevant information from the question. I think now it should be clear enough. –  dyeray Jun 15 at 10:26

1 Answer 1

up vote 1 down vote accepted

If you check out the source, you find the following actions related to the modifications of the navigational menus:

Update:

    /**
     * Fires after a navigation menu has been successfully updated.
     *
     * @since 3.0.0
     *
     * @param int   $menu_id   ID of the updated menu.
     * @param array $menu_data An array of menu data.
     */
    do_action( 'wp_update_nav_menu', $menu_id, $menu_data );

Create:

    /**
     * Fires after a navigation menu is successfully created.
     *
     * @since 3.0.0
     *
     * @param int   $term_id   ID of the new menu.
     * @param array $menu_data An array of menu data.
     */
    do_action( 'wp_create_nav_menu', $_menu['term_id'], $menu_data );

Delete:

    /**
     * Fires after a navigation menu has been successfully deleted.
     *
     * @since 3.0.0
     *
     * @param int $term_id ID of the deleted menu.
     */
    do_action( 'wp_delete_nav_menu', $menu->term_id );

I wonder if you mean these hooks?

share|improve this answer
1  
Thanks, 'wp_update_nav_menu' is exactly what I was looking for. Next time I'll try to check the source... –  dyeray Jun 15 at 10:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.