During the sixth WordPress workshop in Novi Sad, we first took a look at the solution of the task that I gave to the attendees at the previous workshop. We then covered creating membership sites – the WordPress built-in way and by using a plugin Ultimate Member.
Creating a Plugin
During the fifth WordPress workshop, we created a plugin which adds the alt value to all Gravatar images. For homework, everyone was supposed to create a plugin of their own which would add the name of the author in front of the title of each post and
If the post title is Hello World, the end result (instead of just the post title) should be Daki says: Hello World (if Daki is the name of the author of the post). And as a bonus task, the plugin should also add the author’s Gravatar image to the title with the dimensions of 15x15px.
This is a task I made up so there’s no copy/paste solution available online 🙂 However, for finding the right hooks and functions to use, Google is your best friend.
Here’s the function that needs to be added to the plugin in order to achieve the aforementioned result:
And now, the copy/paste solution is available online 🙂
Creating a Membership Site
There are two main ways for creating a membership site in WordPress. The first one is to use the built-in WordPress functionality and publish posts/pages as Private or Password protected. However, this is not a very flexible solution as you can’t really control user capabilities, there’s no members area, and you’d lack lots of really cool options that membership sites have.
Enter Ultimate Member. There are many WordPress membership plugins available online but Ultimate Member is the one I use the most and always recommend. It’s user-friendly and easy to set up. They have decent documentation available and there are quite a few free and premium extensions you can use.
Here’s a video walkthrough of creating a membership site by using the Ultimate Member plugin:
During the video, I’m basically going through the tasks I gave the attendees in order to practice creating a membership site:
- Install and activate Ultimate Member on a site created with the Local by Flywheel application.
- Create the default Ultimate Member pages and add them to the menu.
- Create a new user role that will be the main registration role.
- Allow this role to log into WP Admin and to publish and edit its own post.
- Modify the existing registration form so that it applies only to the new role you created.
- Modify the existing profile form so that it applies only to the new role and allow this user role to insert the following info – Country, Birth date, and YouTube video.
- Add 2 new pages that will be accessible only to the logged in users.
- Add these 2 pages to the menu.
- Modify the menu so that the 2 newly created pages can only be displayed to the logged in users. Do the same for the Logout, Account, and User pages.
- Modify the members directory so that it can be searchable. The searchable users should be only the users who are assigned the newly created role.
- The search can be filtered by Country.
- You can’t see the admin user in the members directory.
- Register as a new user in the browser incognito mode and fill in your profile.
- Create a new user via WP-CLI and set the new role to this user.
- Log into the site as the second user you created (in a new browser) and fill in your profile.
- Check the search functionality and whether it’s working properly.
- With each user, publish one post and add one comment to the restricted pages you added before.
If you’re interested in exploring different membership plugins, Chris Lema has a really nice series of posts on this subject.
As for our WordPress workshops, next Saturday will be the last workshop this year. We’ll have three speakers joining us who will talk about their WordPress beginnings and how they made a career in WordPress. I hope this will further inspire the attendees to dive into WordPress deeply. In my humble opinion, it’s the perfect ending for the workshops 🙂