When running the PayPal subscription extension, you might have some users you want to give a free account to. Or you might want to offer a discount to users with a specific code. Here is are some code snippets that will allow you to validate a promotion code in the registration form and if it is valid, either bypass the PayPal process (for a free subscription) or apply a discount. Continue Reading →
Tips and Tricks
Only Allow Registration From Specified Email Domains
One really fun thing about developing, maintaining, and supporting WP-Members over the years is putting together unique customizations and code snippets based on user requests that I never thought of. It shows how truly versatile the plugin is and that there is a very diverse user base.
This particular snippet comes from a user request to essentially create an email whitelist for registration, thus only allowing registration if the user’s email account is from a certain domain. This can be used in a number of different scenarios. One particular use would be for someone maintaining content for specific business clients and you only want users from those specific client domains to be able to register. Continue Reading →
Workaround for WP-Members front end login when using a CAPTCHA device on the WP login form
If you using a plugin to implement a CAPTCHA on the WordPress login form (the backend login, wp-login.php), you will find that this is not always compatible with the WP-Members front end login.
WP-Members includes WP’s native hooks such as login_form
for broad compatibility with plugins that may add additional authentication to the login. But these are not always compatible with WP-Members or with front-end logins in general.
If the third party plugin does not load its scripts on the front end, it will not be compatible. If you are getting failed logins with strange error messages (such as “human verification incorrect” or something like that), then the issue is likely that a third party CAPTCHA is being used, but cannot authenticate on the front end of the site.
What happens is that in order to implement the CAPTCHA, the plugin must remove the function wp_authenticate_username_password from the authenticate process with remove_filter. This allows the plugin to implement its own authentication that includes not only username and password, but also will validate the CAPTCHA.
This creates a problem since WP-Members also uses WP’s authentication to log a user in. Because the WP-Members form will only be passing two parameters, username and password, and the authentication is now requiring the addition of a third parameter (the CAPTCHA) that is not included in that form, the login will fail.
There are ways to work around this.
Continue Reading →Restrict Post or Page Access to a Specific User
Every once in awhile, I get a question about restricting content (either page or post) to a specific user. There is a limited way to do that with the wpmem_securify filter, similar to the method for blocking content by category and user level.
This process is actually easier than blocking by levels or categories because you only need to determine three things:
- Is the user logged in? If not, then it is blocked regardless.
- If the user is logged in, but not the specified user, it is blocked and an error message is given.
- If the user is logged in and is the specified user, then the content is delivered.
This example will make use of a couple of new action hooks that will allow us to add a dropdown selector of users to the WP-Members post meta box. Continue Reading →
Add a sortable date user registered column to the Users > All Users page
If you manage a site that has a lot of registrations, sometimes it is helpful to show the date the user registered as a custom column in the WordPress admin page Users > All Users. I have shown in another post how you can add that data as well as other data to this table.
But what if you want to make it sortable so you can sort the table by the date the user registered to see what users have registered most recently? Here is a way that you can do that. Continue Reading →