• I’m building a site with Paid Memberships Pro. It’s structured primarily with pages that are assigned to different membership levels. My goal is, when a user is logged in, to show a menu with submenu items representing the pages that member is allowed to see.

    Talking with the PMP developer, he suggested I create a menu per membership level and swap the entire menu out. That’s not ideal because there will be many levels and most will share the same links, so any change would involve changes to every level.

    Is there a way to append menu items to a menu programmatically instead? I am comfortable writing my own plugin to do so.

Viewing 2 replies - 1 through 2 (of 2 total)
  • I’ve used this plugin, may be worth you investigating

    Theme Author presscustomizr

    (@nikeo)

    Hi @roufamatic,
    You can add items programatically to a menu with this filter in WP :
    Menu items can be added manually by applying filters:

    wp_nav_menu_{$menu->slug}_items

    Example where ‘main’ is the main menu slug in Customizr, is_member () has to replaced by the Memberships Pro function to test if user is a member :

    add_filter ('wp_nav_menu_main_items' , 'add_my_custom_item' );
    function add_my_custom_item($items) {
     if ( ! is_member() )
       return $items;
     return $items . '<li class="admin-menu-item"><a href="#custom URL" title="A link title">A menu title</a>';
    }

    Hope this helps!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Modify menu programmatically’ is closed to new replies.