• Log In
  • Welcome
  • Features
  • Pricing
  • Documentation
  • Add Ons
  • Payment Gateways
  • Support
  • Customer Showcase
  • Blog
  • Contact

Log In


Join Now | Lost Password?

Skip to content

Paid Memberships Pro

WordPress Membership Plugin

  • Log In
  • Choose a Plan
  • Features
    • Product Overview
    • Screenshots
    • About Us
  • Pricing
  • Documentation
  • Showcase
  • Add Ons
  • Gateways
  • Support
  • Blog
Home  >  Blog  >  How to Add a Conditional Log in and Log out Link to Your WordPress Menu

How to Add a Conditional Log in and Log out Link to Your WordPress Menu

Estimated reading time: 2 minutes

TweetFacebookLinkedIn

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.

Member Experience Tip: Conditional Log In and Log Out Menu Links
  1. “Log In” and “Log Out” Custom Menu Links

    Customize > Menus > Paid Memberships Pro section

    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.

    View Menus Documentation
  2. 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.


  3. 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.


If you’re on a multisite network, note that these methods may not work 100% as intended. Using the WordPress function in a theme file is the best method for your network/multisite.
Kimberly Coleman

Author: Kimberly Coleman

Kim is co-founder of Paid Memberships Pro. She has her hand in all aspects of the development, management, and marketing for the product and the team. She oversees frontend development for the core open source plugin and Add Ons.

Tagged: log out, login link. Posted in General. Bookmark the permalink. Last updated: May 18, 2020.

Post navigation

← Redirect Members to Referrer on Login
How to Bulk Update User Roles to a Custom Role for Their Membership Level →

Build a membership site—for free.

The fastest way to charge for access to your WordPress site. Our core plugin is free and includes more than other membership plugins. You deserve more.

Start for Free
Choose a Plan

We’re 100% GPL

Our plugin's code is not obfuscated, runs on as many sites as you want and can be customized to fit your project's needs. We just ask that you follow the GPLv2 guidelines by applying the GPLv2 license to any altered or unaltered version of PMPro that you distribute. License Details »

GPL v2

Recent Articles and Updates

  • Banner for What is best for your membership site? Free trial Vs Paid trial
    Free Trial vs. Paid Trial: Which is Best for Your Membership Site
  • Banner Photo of Using PMPro as a WordPress user Profile Plugin
    Can You Use Paid Memberships Pro as a WordPress User Profile Plugin?
  • Banner Image for Dont apply discount if woo products are on sale
    Don’t Apply Member Discount if Woo Products are on Sale

Platform

  • Pricing
  • Features
  • Reviews
  • Screenshots
  • Videos
  • Step-by-Step Guides

Use Cases

  • Associations
  • Blog & News
  • Community
  • Courses
  • Directory & Listing
  • Paid Newsletter
  • Podcast
  • Videos

Add Ons

  • Free
  • Standard
  • Plus
  • Admin
  • Integration
  • View All

Get Help

  • Support
  • Download & Install
  • Hosting
  • Developers
  • Blog
  • Contact Us

Company

  • About Us
  • Work With Us
  • Brand Assets
  • Affiliates
  • Privacy Policy
  • Terms of Service
Follow Us On

© 2023 Paid Memberships Pro. All Rights Reserved.