WordPress chat for registered users with WP Membership

In this tutorial, I will help you to disable CometChat Go for unregistered users on your WordPress website. If you’d like to know how to configure CometChat for WordPress, you can learn from my previous tutorial about installing CometChat Go for WordPress [https://www.

Nathan Sebhastian • Apr 21, 2020

In this tutorial, I will help you to disable CometChat Go for unregistered users on your WordPress website. If you’d like to know how to configure CometChat for WordPress, you can learn from my previous tutorial about installing CometChat Go for WordPress.

If you already have CometChat installed, then you can make CometChat available only to registered users by the steps described in this tutorial.

Disabling CometChat for guests

First, head over to CometChat’s admin panel and go to Settings → Authentication. In here, you need to set the option “Would you like guests to login as well?” to no.

Once you have disabled guest login, you can return to your website. Please make sure you’re not logged in at your WordPress site, then head toward your chat page, and you’ll see that the chat box will be locked. This also works for all docked windows on your website:

Now you can try to login and return to the chat page. You’ll see the chatbox ready for you to use.

You have disabled CometChat for unregistered people, but there is no way for visitors to register as a member on your website. This is where Simple WP Membership plugin comes in.

Setting up a free WP Membership plugin members

Although WordPress can allow anyone to register as a member, I don’t recommend you to make use of it because of the following reasons:

  • The lack of proper registration flow from registration page to login form

  • User roles that only restrict access on the admin pages

  • There are no advanced membership features like paid memberships and affiliates

The default membership system of Wordpress is meant for people who run the website, not the consumer. This is why in order to make a great membership WordPress site, I suggest you use a third party plugin.

Through my experience, I’ve found that Simple WP Membership is a good membership plugin to use with WordPress and CometChat. Let me help you to setup this plugin so that you can let visitors register on your site for free.

First, download the plugin from your WP dashboard and activate it. After that, you need to create a new membership level for your visitors first. This membership level will be assigned to users when they register on your site. Head over to WP Membership → Membership Levels → Add New

You will be served a form to create a new Membership Level. Please fill in the Membership Level Name and Default WordPress Role. You can leave Access Duration to its default value. You can follow my example below:

As for Email activation, I recommend you to turn it on so members can’t register using fake email address. Once you’re done, submit the form by clicking the button. You’ll be redirected to the Membership Levels page list. Take note of the ID on the first left column:

You need to add your free membership level ID to the settings, so click on WP Membership Settings. In here, check the Enable Free Membership box and fill the Free Membership Level ID box with your ID:

Once done, visitors to your site can register as a member already. You can test this by going to the Registration page that’s generated by WP Membership. To find the link, you can go to the near bottom of the same Settings page as above:

Now you can try to register a new account and login. You will see that CometChat is now enabled both on the page and the dock:

Disabling Chat page on the page level

Your CometChat is now accessible by logged in users, but there is one optional step you can do to  offer a better user experience for your visitors. Now that CometChat is open only to registered users, your chat page is essentially a dead end road. Visitors can do nothing there:

You can transform this page from an empty page into an invitation to register or login like this:

In order to do this, you need to edit your chat page and enable Simple WP Membership Protection. You can see the sample picture below:

That’s all you have to do. Now the Chat page will show the message and invite people to login or register to your site.

Conclusion

You’ve just learned how to make CometChat available only for registered users on your WordPress site. Great job on making it to the end!

Aside from Simple WP Membership, you can use other membership plugin to disable CometChat for unregistered visitors. The technical implementation like creating free membership level may be different for other plugins, so you need to look into its documenation. As long as you know how to make the membership system accessible, you should be able to use it with CometChat.

And by the way, I also wrote a tutorial on making CometChat Go a premium feature for paid members only. Which might be interesting for you.

Nathan Sebhastian

CometChat

Nathan, React developer from Indonesia 🇮🇩. Follow me on Twitter @nsebhastian

Try out CometChat in action

Experience CometChat's messaging with this interactive demo built with CometChat's UI kits and SDKs.