The WP-Members 3.4.9 release is mostly a security update, with a couple of additional features and API functions.
Continue Reading →WP-Members 3.4.9
Home of WP-Members, The Original WordPress Membership Plugin
Chad Butler · ·
The WP-Members 3.4.9 release is mostly a security update, with a couple of additional features and API functions.
Continue Reading →Filters the meta keys the [wpmem_field] shortcode can display.
$allowed_fields
(array)(required) An array of the allowed meta keys the shortcode can display.
wpmem_field_sc_meta_keys is located in includes/class-wp-members-shortcodes.php
Chad Butler · ·
I chose the basic email icon that is in the WP dashicons, but there are a couple of dashicon alternatives. And certainly, you could modify this code snippet to use any type of image/icon, such as font awesome. I used the WP dashicons because they are already loaded.
Adding the icon itself (without the link) is nothing more than adding the following span tag to the user profile:
<span class="dashicons dashicons-email"></span>Adding to the user list view can be done with the wpmem_ul_user_rows filter. There is a verbose example below.
add_filter( 'wpmem_ul_user_rows', function( $rows, $list_id ) {
// User ID is a field in the $rows array, get it as $user_id.
$user_id = $rows['ID'];
// User email will be in the $rows array by its meta key (see WP-Members Fields tab).
// HOWEVER, it will have a div wrapper, so we'll strip that out first. (I put them
// in variables to reuse later when we rewrap the field before returnning).
$user_email = $rows['user_email'];
$wrapper_start = '<div class="user_email">';
$wrapper_end = '</div>';
$raw_email = str_replace( array( $wrapper_start, $wrapper_end ), array( '', '' ), $user_email );
// Get the dashicon.
$icon = '<span class="dashicons dashicons-email"></span>';
// Linked icon with the email text.
$email_w_icon = '<a href="mailto:' . $raw_email . '">' . $icon . '</a> ' . $raw_email;
// Put the div tag back.
$rows['user_email'] = $wrapper_start . $email_w_icon . $wrapper_end;
// Return the filtered result.
return $rows;
}, 10, 2 );Chad Butler · ·
While the core plugin restricts posts to logged in users, and can also create memberships for other types of restriction, sometimes you may wish to restrict content to a user role.
This custom code snippet can be copy-pasted to wherever you store custom code and will add a list of roles to the WP-Members restriction meta box in the post editor, and then will restrict the content based on those roles.
Note that this functionality is included in the WP-Members Advanced Options extension.
Continue Reading →There are shortcodes in the plugin that allow you to display a user’s memberships as well as displaying a list of content restricted to a specific membership:
This shortcode displays the memberships a user has available. You can use this anywhere a shortcode can be parsed (which depends on your theme or customizations).
By default, the shortcode outputs a heading and a list of memberships available to the user. There are a number of attributes you can use to customize this output. The following is a list of those attributes and their default values, which you can change as needed.
To display the default list, just invoke the shortcode:
[[wpmem_user_memberships]]To change the heading above the list:
[[wpmem_user_memberships title="Your Available Memberships"]]To remove the heading above the list:
[[wpmem_user_memberships title_before="" title_after="" title=""]]To display a single membership with no title:
[[wpmem_user_memberships title_before="" title_after="" title="" list_before="" list_after="" item_before="<p>" item_after="</p>"]]To display a specific expiration date format, use a PHP date format:
[[wpmem_user_memberships date_format="m/d/Y"]]This displays a list of posts restricted to a membership that the current user has access to. If the user has more than one membership, it will display a list for each.
Attributes:
Ready to get started?