The WPCode Pro plugin comes with a MemberPress integration that allows you to:
- Add custom code snippets
- Set conditional logic for running these code snippets based on your membership
This document will show you how to:
- Set conditional logic for your code snippets based on your MemberPress memberships
- How to run the code snippets only on specific MemberPress pages
MemberPress Conditional Logic Rules
Conditional logic is available for all code snippets added through the WPCode Snippets plugin.
You can:
- Set whether to show or hide each code snippet when a condition rule is fulfilled
- Set condition rules based on pages
- Set condition rules based on whether users are logged in
- Choose if the condition IS or IS NOT matched
With WPCode Pro, this list extends to two MemberPress conditions:
- MemberPress Page
- User active membership
The first condition allows you to set a code snippet to run only on selected MemberPress pages. You can choose the following pages:
- Registration Page
- Thank You Page
- Account Page
- Login Page
The second MemberPress condition allows you to run the code snippet based on whether a user has (or does not have) an active subscription to a specific membership.
How To Set Conditions To Code Snippets
To set conditions for your code snippets using MemberPress conditions, please follow these steps:
- Navigate to Dashboard > Code Snippets > Code Snippets to select your existing code snippet, or click on the “Add Snippet” button to add a new snippet
- Scroll down to the Smart Conditional Logic section and toggle on the “Enable Logic” option
- Select the “Show” or “Hide” option in the first dropdown of your condition, and click the “+Add new group” button
- Select the conditions you need, set the IS or IS NOT operator, and set the needed value. To illustrate, the following code will run only if a user does not have an active subscription for the “MemberPress Yearly” membership:
- You can add additional conditions by clicking the “AND” button, and additional condition combinations (groups) by clicking on the “+Add new group” button again
- Click “Save Snippet” to apply the changes you made
You can set one or multiple memberships for your conditional rules, and combine them with page conditions and available WPCode locations.
For example, you can choose to run a code snippet only on your registration pages, before the registration form, and only for users who are already subscribed for a specific membership.
Help?
Is this not working how you think it should even after following the instructions? Feel free to send us a Support Ticket!