Gravity Ranger
Welcome
Welcome Join for $1
  • Help Docs
  • Tutorials
  • Plugin Reviews
  • Get Help
  • Privacy
  • Log In
© 2026 All Rights Reserved.
Gravity Ranger by WP Mantis LLC
  • Community
  • Classrooms
  • Calendar
  • Members
  • The Vault
  • About

Notifications

No new notifications

Chat

Chat functionality coming soon

Table of Contents

  • How It Works
  • Step 1: Adding the code
  • Step 2: Add your URL slugs
  • Step 3: Adding your shortcode
  • The Wrap Up
Skip to content

Login Logout Shortcode for Gravity Forms Membership Sites

Dec 16, 2021

Tutorials

3 Min. Read

Share URL

This page may contain affiliate links. Please read my disclaimer for more information.

This is not a function of Gravity Forms, but it can be extremely helpful if you’re not using a membership plugin and instead you are using Gravity Forms to build a basic membership site.

I’ve used several different methods for adding the login and logout buttons to a site. I’ve used plugins and other code methods, but this one has been the best solution by far.

I prefer using the shortcode because it will work with any theme and you can put it just about anywhere.

How It Works

All you have to do is add the code below to your themes functions.php file or use a functionality plugin like WPCodeBox (recommended), add your URL slugs and place the [login_logout] shortcode on your site.

Learn more about where to put this code here: https://wpmantis.com/adding-code-snippets-wordpress-site/

Step 1: Adding the code

I will demonstrate how to add this code to your site using the WPCodeBox plugin, you can download it here.

  1. Copy the code below
  2. Go to WPCodeBox (in the WP admin)
  3. Click New Snippet
  4. Past the code in the black box
  5. Add a title
  6. Click Save
  7. Toggle on to enable
https://gist.github.com/chrisegg/11a06ff6d42ac0e165a7db75b8fb4753

Step 2: Add your URL slugs

You will need to add two URLs (or the same URL twice) to the code snippet. The URL will be the location you want the user to be redirected to when they click Login or Logout.

  1. Pick your pages and copy the URL slug, everything after your domain, i.e domain.com/copy-this-stuff
  2. Replace /url-slug-here with your page URL slug
  3. Click Save

Note: using only / will result in redirecting to the homepage.

Step 3: Adding your shortcode

You can use the shortcode anywhere shortcodes are excepted (haha).

In this demonstration I will show you how I add the code to my navigation. This will not necessarily work for all types of themes. I am using the GeneratePress theme which has a header widget area that makes adding a shortcode easy.

You could also use a plugin like, Shortcode In Menus, if your theme does not support widget areas in the header.

  1. Copy the shortcode [login_logout]
  2. Go to Appearance > Widgets
  3. Add the Shortcode block to the header widget area
  4. Paste in the shortcode
  5. Click Update

The Wrap Up

Just to clarify again, this is not a feature of Gravity Forms, this will work without Gravity Forms. I only use this because I ofter use Gravity Forms to create basic membership sites.

This is a simple solution that provides several options for implementation. You can use the shortcode in a page/post, in the footer/header, or in the sidebar.

If you have any questions or issues, please use the comments below.

Tags: login/logout, Membership Site, Shortcodes

Photo of author
About the Author
Chris Eggleston
Husband. Father of 4. Grandpa of 2. Chief Problem Solver exploring business systems, technology, AI & faith — helping people solve real problems. @mantiswp @chrisegg

Support Chris - Donate $5

Gravity Wiz Add-Ons

Advertisement

0 0 votes
Article Rating
Subscribe
Login
Notify of
guest
guest
0 Comments
Inline Feedbacks
View all comments

Related Post

How to Secure a Digital Broadcast Page with Gravity Forms Submit to Access Add-On

Live events and webinars are powerful ways to connect with your audience, but hosting them directly on your WordPress site...

Oct 3, 2025

4 min. read

Step-by-Step Guide: Sending a Gravity Forms Notification to the User

Gravity Forms notification feature allows you to send emails to users automatically when they submit a form. This is useful...

Mar 20, 2025

5 min. read

Gravity Forms Multi-Date Picker

Gravity Forms is a powerful form builder, but you might occasionally find some limitations. For example, the date picker field...

Nov 13, 2024

4 min. read

How to Migrate From WS Forms to Gravity Forms: A Step-by-Step Guide

Migrating from WS Forms to Gravity Forms can seem daunting, but with the right approach, it can be a smooth...

Oct 26, 2024

4 min. read

How to Connect Gravity Forms to SendFox: A Step-by-Step Tutorial

This tutorial will walk you through connecting Gravity Forms to SendFox and ensuring your contacts are added to your email marketing...

Oct 16, 2024

5 min. read

How to: Gravity Forms BMI Calculator

Many people don’t realize that the calculation feature is built into the Gravity Forms core plugin and is available for...

Oct 10, 2024

4 min. read

wpDiscuz
  • Go to classroom

  • Upgrade membership