Adding a membership to your Wix website is a great way to give your visitors access to exclusive content or features. There are two ways to add a membership to your Wix site: through the Wix editor or using Wix Code.
Adding a membership through the Wix editor is simple and doesn’t require any coding. Just follow these steps:
Exciting update! We've collaborated with Wix to offer WBI users with a free plan for all website creation needs - Explore the details here.
1. Log in to your Wix account and open the Editor.
2. Click Add on the left side of the Editor.
3. Click Membership, then click Create Membership.
4. Select a membership type and enter your payment details.
5. Customize your membership pages and settings.
6. Click Publish.
If you want more control over your membership levels or you want to add other features to your site, you can use Wix Code. Adding a membership with Wix Code gives you access to functions that are not available in the Editor, like customizing the registration process or adding an automatic renewal feature.
Follow these steps to add a membership with Wix Code:
1. Click “Add” on the left side of the Editor.
2. Click “+New Page”, then click “Blank Page”. Give your page a name and click “Create”
3. In the page code, paste this code snippet:
import wixData from 'wix-data';
$w.onReady(function () {
$w("#button1").onClick(async () => {
let membershipName = "YOUR_MEMBERSHIP_NAME_HERE";
let membershipDuration = 12; //in months
let membershipPrice = 9.99;
let membershipBenefits = "Access to premium content";
let isMember = await wixData.isMember(membershipName);
if (isMember) {
console.log("User is already a member");
} else {
wixData.becomeMember(membershipName, membershipDuration, membershipPrice, membershipBenefits);
}
});
});
This code snippet creates a button that, when clicked, checks if the user is already a member of the specified membership level. If the user is not a member, the script will add them to the membership. You can customize the membership name, duration, price, and benefits by replacing the placeholder values in the code.
4. Replace “YOUR_MEMBERSHIP_NAME_HERE” with the name of your membership level.
5. Customize the rest of the code to fit your needs. For example, you can change the price, duration, and benefits of your membership.
6. Save your changes by clicking the “Save” button in the top menu.