Show Member's post in nav bar when logged in

Hi.

I would like to show the logged in member of a hidden post to see a link to that hidden post in the nav bar when logged in for ease of access.

If I have 3 membership plans how do I show that specific hidden post link on my nav bar, hiding all other hidden posts which that member is not a member of when logged in?

(I'm sorry to ask, I knew how to do this 2 years ago using the old Membership module)

  • Milan

    Hello David

    Hope you are well today and thanks for asking us. :slight_smile:

    First of all, please don't be sorry, we are hear to help you out. :slight_smile:

    So what do you want to achieve here is this ?

    #1) You want to show custom link in your menu for members of any one particular membership.
    #2) Link should be hidden for all other members.

    Right ?

    If this is what you want to see in action, we can do this by following these steps. :slight_smile:

    #1) Activate Advance Menu Protection Addon from "Membership 2 > Addon > Advanced menu protection"
    #2) Click on its option, Chose "Replace Individual Menus" option.

    #3) Create two different menus from "Appearance > Menus" like this,
    #3.a) One menu for all people
    #3.b) One menu for only members of specific membership
    #4) Go to Membership 2 > Protection Rules > Replace Menus
    #5) Chose membership which is for displaying hidden link for "Who has Access" column.
    #6) Replace generalised menu with the one which is specific to hidden link one membership.

    Wait till all changes gets saved and then test. :slight_smile:

    Hope this helps. If I've missed something obvious, please do let me know. :slight_smile:
    Cheers,
    Milan

  • David

    Hi ANd thank you for the reply.

    This is kind of on the right track but not exactly it. Your scenario presumesI need to create the entire menu structure every time I add a membership which means rebuilding the menu dozens of time.

    The original structure had it so I could have one menu but certain pages or posts would only appear on the singular menu if I were logged in and other options would not appear if I were logged in.

    Example: a link to post 1 would be hidden unless I was logged and a member of the member plan associated with post 1.

    Example: a link to post 2 would be hidden unless I was logged and a member of the member plan associated with post 2.

    Example: a link to register for site would only appear if I were a guest and not logged in. It would not appear if I were logged in.

    Example: a link to accounts would only appear if I were logged into the site.

    These are all scenarios that worked with another site I developed using the original plugin. Same Primary menu. 1 menu.

    Original Tutorial:

    https://www.youtube.com/watch?annotation_id=annotation_493483&feature=iv&src_vid=Vx40vC9mQGM&v=wujmWc4u7ds

    This shows scenarios where links like "Hidden Page" only appears on nav bar with proper permissions.

    How do I add this same functionality using the Membership 2 plugin?

  • Milan

    Hello David

    It seems to me that you want to protect Single Menu item, Please change Membership 2 > Add on > Advanced Menu Protection > Details > Choose how you want to protect your WordPress menus to Protect Single Menu Item( Default )

    Then just go to Membership 2 > Protection Rules > Menu Items and define your protection rules. :slight_smile:

    Hope this helps you. :slight_smile:
    Kind Regards,
    Milan

  • David

    Hi.

    Thank you for replying. This looks good. Just takes work to set up the menu and I can see this list getting quite long.

    QUESTION: Is there a way to set it up where I add the Category Serial Number onto the nav bar and have the List of posts that appear when I click on it ONLY show the membership(s) that I am a member of? That would work better than manually adding each SN to the drop down list. Right now if I add the Category Serial Numbers to the Nav bar and click on it it shows the entire list even though they are membership protected.

    Please advise.

  • Adam Czajczyk

    Hello David!

    Does it mean that you'd like to hide entire drop-down sub-menu if a parent menu item is protected?

    Currently using Menu Protection add-on you can either protect entire menu (swap menus depending on membership) or protect individual items. In this case it seems that only the latter one is a solution and it requires protecting each and every single item. However, if a parent menu item is not visible (due to protection) the sub-menu will not be visible as well.

    To sum it up:
    - parent menu item is protected and is invisible for current membership - entire sub-menu will not show as well
    - parent menu item is available for current membership - sub-menu items must be individually protected.

    It may be possible to make it more "universal" and implement some advanced "dependencies" but it would require custom coding. The Membership 2 Pro includes an API that may be useful and is documented "in plugin" on "Membership 2 -> Help -> API Docs" page in your site's dashboard.

    Kind regards,
    Adam

  • David

    Hi.

    Thanks for the reply.

    The surprising thing today is to find the category is already doing what I want it to do?

    If I am the admin I see all protected links here: http://162.144.73.104/~taggedbyanangel/category/serial-numbers/

    If I am logged in as a member of only one protected post ONLY that post appears on the list. '

    If I am not a member of any post then I receive a page cannot be found page.

    Functionally this is perfect. My only qualm now is the page cannot be found message here:

    No posts found

    Sorry, but nothing matched your search criteria.

    Go back, or return to Tagged by An Angel home page to choose a new page.
    Please report any broken links to our team.

    Where may I modify this message for this category?

  • Predrag Dubajic

    Hi David,

    Since posts are not loaded for visitors it will show default theme message for category without posts so it might be difficult to change this message as it's the message show on all category pages and search page as well if search criteria doesn't match any content.

    Can you tell us which message are you looking to show there so we can see if there's any workaround we can do here for you?

    Best regards,
    Predrag

  • Dimitris

    Hey there David,

    I hope that you're having a beautiful day and don't mind skipping in! :slight_smile:

    As Predrag had mentioned you, this is coming from your theme actually. For example, TwentySixteen theme and its archive.php file, which leads into the "Oops! That page can’t be found.".
    If you cannot locate the exact template file that is being rendered at that time, there's a simple plugin called Reveal Template that can do the trick for you. :wink:

    Unfortunately, I was unable to enter your website, despite that as far as I can see, it has been granted for support staff. Please do make a second check that support access is enabled and I'll ping my colleagues on this too.

    Warm regards,
    Dimitris

  • Adam Czajczyk

    Hell David!

    I accessed your site and checked the theme. I can see that you're already using a child theme so that's very convenient because in order to personalize the "No posts found...." content you will want to change one of the template files.

    I'm not 100% sure yet but I believe the template file to change would be the "templates/no-articles.php" file. First step would be to copy that file from the parent theme folder to the child theme folder. Make sure that you use the same path so while "no-articles.php" file is inside "templates" folder in parent theme folder it should be put into the "templates" folder inside child theme's folder as well :slight_smile:

    In this template there's a part of code that displays that entire "NO POSTS FOUND...." content block:

    <h2 class="post_title"><?php esc_html_e('No posts found', 'organics'); ?></h2>
    				<p><?php esc_html_e( 'Sorry, but nothing matched your search criteria.', 'organics' ); ?></p>
    				<p><?php echo wp_kses( sprintf(__('Go back, or return to <a href="%s">%s</a> home page to choose a new page.', 'organics'), home_url(), get_bloginfo()), $ORGANICS_GLOBALS['allowed_tags'] ); ?>
    				<br><?php esc_html_e('Please report any broken links to our team.', 'organics'); ?></p>
    				<?php echo trim(organics_sc_search(array('state'=>"fixed"))); ?>

    This could be "wrapped" in an "if... else..." conditional statement. I think it would be enough to create condition based on current category as Membership 2 Pro would take care of the rest. Basically, you'll want to display your custom message instead of this default content if currently viewed category is "serial-numbers" and display the default content ("No posts found") if it's any other category.

    A logic (in "pseudo code") would be like this:

    if (is category "serial numbers") {
      display custom message
    }
    else
     display default message
    }

    I hope that makes sense. Below is a proposed code that you could use to replace the default one (quoted above in this post):

    <?php
    if (is_category('serial-numbers')) {
    	?>
    
    	PUT YOUR CUSTOM "NOT FOUND" MESSAGE HERE
    	you can even show a "buy membership" button here
    	using a shortcode like this:
    
    	<?php echo do_shortcode('[ms-membership-buy id="5" label="Buy now!"]'); ?>
    
    	<?php
    }
    else {
    // for any other category just show default content block
    	?>
    
    				<h2 class="post_title"><?php esc_html_e('No posts found', 'organics'); ?></h2>
    				<p><?php esc_html_e( 'Sorry, but nothing matched your search criteria.', 'organics' ); ?></p>
    				<p><?php echo wp_kses( sprintf(__('Go back, or return to <a href="%s">%s</a> home page to choose a new page.', 'organics'), home_url(), get_bloginfo()), $ORGANICS_GLOBALS['allowed_tags'] ); ?>
    				<br><?php esc_html_e('Please report any broken links to our team.', 'organics'); ?></p>
    				<?php echo trim(organics_sc_search(array('state'=>"fixed"))); ?>
    
    	<?
    }
    ?>

    Please note: it's not an entire template but just a "replacement part" for default "NO POSTS....." content.

    Let me know please if it helped!

    Best regards,
    Adam

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.