Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Making WordPress’ page and menus visible only for logged in users, checking session variables

I think @Milo’s comment is correct. Presumably you want to use functions like current_user_can(), etc.
Alternatively, if this is just to show a different menu, you could create a custom menu for remote users then set a cookie on your wordpress site (via a call from the API) and display a different menu to your remote users when authenticated remotely.

add_filter('wp_nav_menu_args', 'wpse_wp_nav_menu_args_filter');
function wpse_wp_nav_menu_args_filter($args = array()) {
   if ($_COOKIE["remoteuser"] == "loggedin") { // User is remotely authenticated
        // Setup Primary Menu
        if ( $args['theme_location'] == 'primary' ) {
            $args['menu'] = "remote_user_menu";
        } 
        return $args;           
    }   else {
        return $args;       
            }
}

You could then use something along the same lines to determine whether a page should be visible or not.

Related Posts:

  1. Add “Logout” link to navigation menu
  2. wp_nav_menu: show menu only if one exists, otherwise show nothing
  3. Add child pages automatically to nav menu
  4. Automatically remove trashed pages from nav menu
  5. Directing a page to a default subpage
  6. Can you have different menus and theme on a per-page basis?
  7. Add a logout menu link [duplicate]
  8. List children of second level sub page
  9. How to make pages metabox display all hierarchy in menu admin?
  10. Add log in link to menu in Twenty Twelve
  11. add the user name to menu when user is logged in [closed]
  12. How to get current page menu item name instead of full menu item list
  13. Hide pages depending on role
  14. Get parent page/menu id of current post
  15. Is it possible to show a different WP menu when using password protected pages?
  16. How do I approach removing menu items on the fly based on settings in my plugin?
  17. Change menu items URL
  18. wp_nav_menu log in/out link?
  19. Different side menu on each page
  20. WordPress – site with 2 stylesheets and more…
  21. Remove Page Name From WordPress Menu
  22. Hiding Menu From Specific Pages
  23. Getting post content within wp_nav_walker
  24. wp_list_pages sort order is different for different languages [closed]
  25. list pages only from master parent
  26. wp_list_pages: only show subpages on the parent page?
  27. Show menu item only if user is logged In (not word press login)
  28. Auto add pages to primary menu with functions.php
  29. Does loading of sub pages in menu cause load to the server?
  30. WordPress menu permalink redirects to wrong page
  31. Link to Homepage in Menu
  32. Schedule Page to Menu [duplicate]
  33. Add class active to static menu
  34. wp_list_pages() but only show children on the branch you are on
  35. Check if Page Already Exists in Menu
  36. Programmatically add existing pages and subpages to Appearance Menu
  37. How to retrieve parent menu item name of current submenu item
  38. two different separate sections on the same site
  39. When clicking on menu item not going to specific page
  40. Ad custom admin page like WordPress customizer [closed]
  41. Displaying different page links on different pages
  42. Create custom page and add it in nav menu by code
  43. Use another menu when logged in
  44. Does is_child() exist in wp 3.5.1?
  45. wp_list_pages sort order by custom nav menu order
  46. How to highlight 1st level menu item based on actual page
  47. How can I switch pages?
  48. Prevent menu from loading in a page template [duplicate]
  49. How to create a menu item which is not a page
  50. How can I make a menu link visible only to admins (without plugins)?
  51. How to add a page to header that is outside of WordPress?
  52. How to Structure Pages and Subpages
  53. Highlighting top level link when viewing one of it’s sub-pages, which are not linked in the menu
  54. Three menus – parent / child / sibling
  55. Add (grand)child pages automatically to nav menu
  56. how avoid the link of the current post in the menu in the sidebar?
  57. How to Show Different Menus to Logged in Users in WordPress [duplicate]
  58. Disable parent in wp_list_pages – WordPress
  59. Page appears after de registering from menu
  60. Get parents child pages
  61. login logout menu changes in wordpress [closed]
  62. Dynamic menu wp_list_pages displaying only current branch including: current page, his siblings and its childs
  63. wp_nav_menu without menu or theme_location specified
  64. WordPress Login/Logout Single Menu Only
  65. I can’t add more pages to menu – menu delete pages
  66. wp_list_pages Hierarchical Help
  67. Parent Page > Child Page Menu
  68. Making pages in a menu appear conditionally
  69. Add pages content to startpage through custom menu
  70. add_menu_page does not render the expected result
  71. Main menu navigation links and new pages
  72. Page header menu links change
  73. Catagorized hierarchy menu for PAGES!
  74. How to show pages in menu without link
  75. Add a menu metabox to post edit page
  76. Setting or plugin for showing submenus horizontally under the main menu, and keep them after selection
  77. Page dependent sub-menu?
  78. WP pages content is missing in frontend
  79. Using WP page password protection as defacto login
  80. Unable to remove page from primary menu
  81. how to create pages and link them to a menu
  82. How to sort a sub-menu, generated with get_pages(), by the page order instead of alphabetically?
  83. Any simple way to show 10 previous pages by id to current page in links as a menu
  84. How to add class and span to
  85. Specific Page that convert Hyperlink to anchor in nav menu
  86. Change “login/register” to “useraccount” when a user has logged in
  87. WordPress – Apperance > Menu
  88. Creating and populating custom nav menu (menu-item-position not working)
  89. How to make a page to not appear in the menu when created?
  90. Two pages named the same thing, on a different level but conflicting url paths in menus and direct links
  91. Site with all content on the front page
  92. Adding Pages to Menus – No Page Hierarchy in Backend [duplicate]
  93. Some informations about the use of statics pages in WordPress
  94. How can I make this process automatic?
  95. my theme automatically adds new pages to menu
  96. how can i get the page_ID in nav li [closed]
  97. How does WP knows which template to use for a page
  98. Problems with draft website pages
  99. Add a page to a subscribers account
  100. Control page access based on User Meta data?
Categories menus Tags login, menus, pages, wp-login-form
WordPress Fatal error: Call to undefined get_header() in index.php on line 15 [closed]
Using Checkboxes on Plugin Options Page for Custom Plugin

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress