This is an idea that has been floated by a few users, which means there is probably a need for it. As is usually the case, I don’t like to make wholesale changes to the codebase that effects users in a way that requires them to make a change to accommodate an update. So I wouldn’t want to change the plugin to put in different classes, since users with a custom stylesheet would need to be paying attention when they update to accommodate the new classes in their stylesheet. But this is something that we can certainly do on the fly using the wpmem_msg_dialog filter. This article will show you how to do just that. Continue Reading →
Search Results for: short code
wpmem_recaptcha_score
Description
This is a filter hook that allows you to modify the spam score used by reCAPTCHA v3.
reCAPTCHA v3 returns a score (1.0 is very likely a good interaction, 0.0 is very likely a bot). Based on the score, you can take variable action in the context of your site.
The default value used in the WP-Members plugin is 0.5. Use the filter to allow registrations with a lower value, or restrict to registrations with a higher value as needed.
More information from Google’s documentation for reCAPTCHA version 3.
Parameters
$score
(integer)(required) The score required to allow the captcha to pass (0.0 – 1.0). Use a lower value to allow more registrations, higher to restrict more registrations.
Example
add_filter( 'wpmem_recaptcha_score', function( $score ) { /* * Return a score between 1 and 0.1. * A lower score will let through more results. */ return 0.3; });
Changelog
- Introduced in extension version 3.3.9
Source
wpmem_recaptcha_score
is located in /includes/class-wp-members-recaptcha.php
Create a sidebar login status and logout link
In some layouts, you may wish to not use the WP-Members sidebar widget for logging users in, but you may still want to display a user’s login status (when logged in) and provide a logout link. Here is how you can do that with a plain text widget. Continue Reading →
Redirecting WordPress urls for login, logout, and registration
Depending on a number of factors, there may be places in your WordPress site where login and logout URLs are directing to the WordPress “backend” wp-login.php. These can be in the comments.php template or other places in your theme. Also, various plugins such as forums will utilize these urls.
This article will explain a simple way of redirecting these URLs to the login and registration pages set in WP-Members.
NOTE: The WP-Members Advanced Options extension has simple checkbox options to replace the native WP URLs for these actions with the WP-Members URLs.
Continue Reading →wpmem_securify
Description
This filter hook allows you to filter the $content
container variable based on your own filter criteria.
This filter is part of the do_securify()
function, which is a filter function hooked to the_content and runs at a priority of 99 (late). The filter hook comes at the end of the function and will contain whatever is in the $content
variable at that point. This may be the post content if unblocked or the user is logged in, or the login/registration form if the user is not logged in.
This filter can be used to add additional criteria for displaying content (such as levels, groups, or other individual user criteria), or it can be used to do additional filtering on the content as needed.
Parameters
$content
(string)(required) The $content variable after the do_securify() function has run.
$orig_content
(string)(optional) The original $content variable before being filtered.
Examples
The basic setup:
add_filter( 'wpmem_securify', 'my_securify_filter' ); function my_securify_filter( $content ) { /* * This can filter the content that is returned. * * If you have additional criteria you want to set to * block content, such as a custom post type, or a user * level, this is the filter you want to use. In that * case, return an error message (or other content) if * additional criteria are not met. */ return $content; }
Here is a theoretical example where a custom user field “extra_access” is checked. If the user is logged in, the content is blocked, and they do not have “1” as the “extra_access” value, then an error message is returned.
/** * Here is a theoretical example where additional user * criteria based on a custom user field "extra_access" * is checked. If the field "extra_access" is not "1" * then an error message is returned. */ add_filter( 'wpmem_securify', 'my_securify_filter' ); function my_securify_filter( $content ) { // If the user is logged in and the content is blocked. if ( is_user_logged_in() && wpmem_is_blocked() ) { $user_id = get_current_user_id(); $extra_access = get_user_meta( $user_id, 'extra_access', true ); if ( 1 != $extra_access ) { return "You do not have extra access!"; } } return $content; }
Changelog
- Introduced in version 2.7.7
- Moved to do_securify() in WP_Members object in 3.0.0
Source
wpmem_securify is located in includes/class-wp-members.php
Code Snippet Library [Subscriber Content]
- Replace the default login and registration forms with buttons
- Restrict a post or a page to a specific user role – multiple select version
- Restrict Post or Page Access to Specific Users – Multiple Select Version
- Restrict a post or a page to a specific user role
- Restrict content by user level
- How to restrict categories to a defined user group
- Restrict Post or Page Access to a Specific User
- How to add multiple user levels by category
- Blocking content in a custom template