Support » Plugin: Duplicate Menu » Integrate with Nav Menu Roles plugin?

  • Resolved John Sundberg


    Hi Jonathan,

    I found Duplicate Menu yesterday after it occurred to me that I should make a copy of a fairly intricate menu on an intranet that I built earlier this year. That intranet has multiple custom user roles, and I used the Nav Menu Roles plugin to control who can see what menu items.

    When I duplicated that menu the only things that didn’t get copied were the menu item settings for Nav Menu Roles. I worked on this for a couple hours this morning, trying different approaches to add the NMR custom keys to the array in duplicate-menu.php, but I eventually ran out of ideas.

    Here’s a link to the Nav Menu Roles thread where that developer said she thought I should approach you regarding Duplicate Menu supporting custom menu item keys: Integrate with Duplicate Menu plugin?


Viewing 4 replies - 1 through 4 (of 4 total)
  • If it helps, I looked over the main plugin file and there is definitely nothing that looks at and duplicates the menu item’s post meta… which is where Nav Menu Roles is storing its details.

    A pair of suggestions would be to borrow from this article:

    $post_meta_infos = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->postmeta WHERE post_id=$post_id");
    if (count($post_meta_infos)!=0) {
    	$sql_query = "INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) ";
    	foreach ($post_meta_infos as $meta_info) {
    		$meta_key = $meta_info->meta_key;
    		$meta_value = addslashes($meta_info->meta_value);
    		$sql_query_sel[]= "SELECT $new_post_id, '$meta_key', '$meta_value'";
    	$sql_query.= implode(" UNION ALL ", $sql_query_sel);

    or maybe a loop with get_post_custom():

    $custom_fields = get_post_custom($post_id);
    if( $custom_fields ) foreach ( $my_custom_field as $key => $value ) {
    	update_post_meta( $post_id, $key, $value );

    I don’t know which would be more efficient.


    Plugin Author Jonathan Christopher


    Hello, while I wouldn’t consider supporting that specific plugin I will definitely implement a hook to support that behavior. I’ll update this thread when an update has been released.

    Plugin Author Jonathan Christopher


    Version 0.2 has just been released which includes a new hook: duplicate_menu_item

    In context:

    This hook can be used to extend Duplicate Menu to support custom meta processing as you’ve outlined.

    Thanks Jonathan!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Integrate with Nav Menu Roles plugin?’ is closed to new replies.