Option 1 – WP Nav Menus
In your portal page template (or even in your header template) you can use wp_nav_menu() combined with is_user_logged_in() to print one of two menus.
wp_nav_menu( array(
'theme_location' => is_user_logged_in() ? 'logged-in-menu' : 'logged-out-menu'
) );
Now you’ll need to create two menus in the WordPress admin under Appearance > Menus. One menu is your normal site menu, and the other is your special menu for logged out users which contains only a link to the login page.
You’ll need to replace 'logged-in-menu'
and 'logged-out-menu'
with either the slug (eg: 'slug'
), id (eg: 18
), or the name (eg: 'Menu Name'
) of the two menus you created. See the documentation linked above for more info.
Option 2 – Simple Buttons
On your portal page template, you could add one of two buttons based on whether the user is logged in. Change the markup to your liking.
if ( is_user_logged_in() ) {
// user is logged in
?>
<a href="https://wordpress.stackexchange.com/">Enter Site</a>
<?php
} else {
// user is not logged in
?>
<a href="http://wordpress.stackexchange.com/wp-admin/">Please Log In</a>
<?php
}
Option 3 – Use a Plugin
Plugins exist that will conditionally show menu items based on user login, role, etc. One that I know of offhand is the WPFront User Role Editor. I believe the free version of that plugin will do what you want.