0

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?

2
  • The question is not clear.
    – s_ha_dum
    Jun 15, 2014 at 1:45
  • I removed some irrelevant information from the question. I think now it should be clear enough.
    – dyeray
    Jun 15, 2014 at 10:26

1 Answer 1

1

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?

1
  • 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, 2014 at 10:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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