This post covers a few methods to add a “Log In” and “Log Out” link to all the places where a user would expect to see them on your website. Use one of the options below to add a conditional “Log In” link to a Menu in the WordPress Appearance > Menus admin page.
“Log In” and “Log Out” Custom Menu Links
Paid Memberships Pro adds a new section to the “Menus” administration pages in your WordPress dashboard. This section includes all core pages created by the plugin, as well as links for member login and logout. These unique links can both be placed in any menu location and will be shown/hidden based on the user’s login status.
Use the Memberlite Theme
The Memberlite Theme has a built in log in / log out menu area in the upper right area of your WordPress site. You can enable this feature on the Appearance > Customize > Memberlite Options screen in the WordPress admin. Check the option to “Show Login/Member Info in Header”.
If the user is logged in and Paid Memberships Pro is active, the member will see their display name linked to the ‘Membership Account’ page, alternately they will see their display name linked to the ‘Edit Profile’ page.
You can add a members menu to this area under Appearance > Menus screen in the WordPress Admin. Read more about Memberlite menu options here.
Custom Code the Menu In Your Theme or via a Custom Filter
If you’re comfortable with editing your theme, you can add the login/logout link anywhere you would like via this function:
<?php wp_loginout(); ?>
The function has two parameters:
<?php wp_loginout( $redirect, $echo ); ?>
- $redirect: (optional) URL to redirect to on login/logout.
- $echo: (optional) If true, echos the link, if false, returns the link as a string. (default: true)
Read more about this function at the WordPress codex, including how to filter a wp_nav_menu
to add the conditional link via a custom function.
Download the free ebook: Get 29 insights and ‘aha moments’ for new or veteran membership site business owners. Use these nuggets of wisdom to inspire or challenge you.