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.
- Copy the code below
- Go to WPCodeBox (in the WP admin)
- Click New Snippet
- Past the code in the black box
- Add a title
- Click Save
- Toggle on to enable
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.
- Pick your pages and copy the URL slug, everything after your domain, i.e domain.com/copy-this-stuff
- Replace /url-slug-here with your page URL slug
- 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.
- Copy the shortcode [login_logout]
- Go to Appearance > Widgets
- Add the Shortcode block to the header widget area
- Paste in the shortcode
- 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.