OnPoint Plugins

  • Plugins
    • Advanced Sidebar Menu
      • Basic Version
        • Documenation
        • Usage
        • Developer Docs
      • PRO Version
        • Demo
        • Usage
        • Developer Docs
    • Go Live Update Urls
      • Basic Version
        • Documenation
        • Usage
        • Troubleshooting
      • PRO Version
        • Demo
        • Usage
        • URL History
  • About
    • Services
    • Showcase
  • Blog
  • Contact
  • Support
  • Log In
← Back to support

Members plugin: Hide posts if user doesn’t have access

Resolved

Requested: 1 year and 5 months ago

Hi OnPoint,

I’m need to hide items in the ASM-menu containing Posts in specific Categories, that the current (logged in) user doesn’t have access through via Member plugin. Similar as required in this post: https://onpointplugins.com/plugin-support/hide-pages-if-user-doesnt/

But instead of Advanced Sidebar Menu PRO – Pages it regards Advanced Sidebar Menu PRO – Categories.

Is this possible?

Thanks in advance!

Best regards,
Fredric

 

 

 

Plugin: Advanced Sidebar Menu

  1. Avatar for OnPoint PluginsOnPoint Plugins

    1 year and 5 months ago

    Hi Fredric,

    You may exclude posts from the “Advanced Sidebar – Categories” menus by adding the following custom filters to your active theme’s functions.php file.

    Have a great day!

    P.S. I’ve added a new advanced-sidebar-menu-pro/walker/display-posts/children filter to the Advanced Sidebar Menu PRO plugin which will simplify this type of adjustment in the future. It will be available in the next version (not yet scheduled).

  2. Avatar for Fredric OllerstamFredric Ollerstam

    1 year and 5 months ago

    Dear OnPoint,

    I tried the code, but I got an error, see the private info.

    //Fredric

  3. Avatar for OnPoint PluginsOnPoint Plugins

    1 year and 5 months ago

    Hi Fredric,

    I see what happened. The Category class is not in use.

    Here is a version which does not require it.

  4. Avatar for Fredric OllerstamFredric Ollerstam

    1 year and 5 months ago

    Hi,

    Thanks! That worked just fine!
    Though, sorry, I have a follow up question.

    Is it possible to hide the parent categories if it doesn’t contain any post the users has rights to access?

    I’ve tried different settings in the backend without success.

    Thanks!
    Cheers,
    Fredric

  5. Avatar for OnPoint PluginsOnPoint Plugins

    1 year and 5 months ago

    Hi Fredric,

    I have updated the above filter to also exclude categories which do not have any posts to display. It is a bit heavy to check for available posts during the display of each category but I did what I could to reuse the results and reduce the number of queries.

    I’m guessing a bit on context so here is what the filter will do:

    1. Exclude any posts from the menu.
    2. Exclude any categories from the menu which don’t have
      1. Child categories. (or)
      2. Posts to display.

    Have a great day!

  6. Avatar for Fredric OllerstamFredric Ollerstam

    1 year and 5 months ago

    Hi!
    Great thanks!!

    Though I could see it wouldn’t handle Parents with Parents correctly aka handling the scenario where a parent/parent category has child categories but no accessible posts due to user permissions.

    I did some testing myself and with a little help with AI I ended with an adjustment that also hide the Parents with Parents.
    I’ve added the adjustment to the private info since it might not be 100% and might generate unwanted loops or excessive recursive calls if used in a different setup. Maybe that could be solved with memoization/caching.

    Again, thanks!!
    Cheers,
    Fredric

New Response Cancel reply

You must be logged in to respond. Only PRO members are allowed to respond to support requests.

© 2025 · WordPress Development · Terms Of Service · Privacy Policy · Cookie Policy · Log in

  • Plugins
  • Blog
  • Contact