WP-Members 3.1.8 is complete and is now available for upgrading.
Here is what’s in store for you in this new release: Continue Reading →
Home of WP-Members, The Original WordPress Membership Plugin
Chad Butler · ·
WP-Members 3.1.8 is complete and is now available for upgrading.
Here is what’s in store for you in this new release: Continue Reading →
Filters the default settings for WP-Members’ user export process.
Defaults:
$defaults = array(
'export' => 'all',
'filename' => 'wp-members-user-export-' . date( "Y-m-d" ) . '.csv',
'fields' => $export_fields, // (from wpmem_export_fields fitler)
'entity_decode' => false,
'date_format' => 'Y-m-d', // Use PHP date format
'required_caps' => 'list_users', // WP capability required to export
'export_fields' => '', // Deprecated 3.4.0, use 'fields' instead.
'exclude_fields' => '', // Deprecated 3.4.0, use the wpmem_export_fields filter hook instead.
);$args
(array) (required) An array of any defaults being changed.
$tag
(string) (optional) The export being performed, default value: “default“
/**
* This example sets the export function to decode HTML entities
* in the export.
*/
add_filter( 'wpmem_export_args', 'my_export_args' );
function my_export_args( $args ) {
$args['entity_decode'] = true;
return $args;
}wp_parse_args() to fill missing defaults$tag parameterexclude_fields (unset using wpmem_export_fields instead)export_fields, use fields insteadwpmem_export_args is located in includes/class-wp-members-user-export.php
This filter allows you to make changes to the fields settings array before the fields are passed to the form building functions. This allows you to add/subtract fields from different forms and/or on different pages.
For example, you may wish to display fields on the user profile update that are not included in registration. This function allows you to make those changes in one place so that you do not have to worry about filtering the fields out of the form and then also filtering them for processing. Both are handled by this filter.
$fields
(array) (required) The form fields settings array.
$tag
(string) (optional) Indicates the process for the form (register|profile|register_wp|profile_dashboard|profile_admin).
Remove default address/phone fields from the WP-Members registration form, but not the user profile update form:
/**
* This example removes the WP-Members default address/phone fields
* from the form if it is being displayed for registration, but
* would leave them in for user profile update or any other
* process.
*/
add_filter( 'wpmem_fields', 'my_remove_reg_fields_filter', 10, 2 );
function my_remove_reg_fields_filter( $fields, $tag ) {
if ( 'register' == $tag ) {
unset( $fields['billing_address_1'] );
unset( $fields['billing_address_2'] );
unset( $fields['billing_city'] );
unset( $fields['billing_state'] );
unset( $fields['billing_postcode'] );
unset( $fields['billing_country'] );
unset( $fields['billing_phone'] );
}
return $fields;
}Similar to the above example, but uses an array of meta keys, removing from the registration form any field whose meta key is in the array.
/**
* Remove fields from the registration form using and array of
* meta keys. Loops through the array to remove (unset) fields
* found in the array from the settings.
*/
add_filter( 'wpmem_fields', 'my_remove_reg_fields_by_array', 10, 2 );
function my_remove_reg_fields_by_array( $fields, $tag ) {
if ( 'register' == $tag ) {
$remove_meta = array ( 'billing_address_1', 'billing_address_2', 'billing_postcode', 'billing_country' );
foreach ( $remove_meta as $meta ) {
unset( $fields[ $meta ] );
}
}
return $fields;
}An example of removing a field from the user profile update form but not the registration:
/**
* This example removes a field (in this example - phone1) from
* the user profile update. That way, the user cannot update
* or change this field after registration.
*/
add_filter( 'wpmem_fields', function ( $fields, $tag ) {
if ( 'profile' == $tag || 'profile_dashboard' == $tag ) {
unset( $fields['phone1'] );
}
return $fields;
}, 10, 2 );
/**
* Same as above for several field meta keys in an array.
*/
add_filter( 'wpmem_fields', function ( $fields, $tag ) {
// Only remove if we're on the profile or profile_dashboard view.
if ( 'profile' == $tag || 'profile_dashboard' == $tag ) {
// An array of field meta keys to remove.
$remove_fields = array( 'my_field1', 'my_field2', 'my_field3' );
// Loop through the array and unset the key from the $fields array.
foreach ( $remove_fields as $remove_field ) {
unset( $fields[ $remove_field ] );
}
}
return $fields;
}, 10, 2 );The array key for each field in the array is its meta key. Each field in the array is an array of setting values as noted below.
All fields must include the following:
The following values are supported by all fields, but are optional (the above are required)
The following values are supported by text, url, email, and password field types.
The following values are supported by the number field type:
The following values are supported by the date field type:
The following values are supported by the checkbox field type:
Introduced in version 3.1.7
wpmem_fields is located in includes/api/api-forms.php
Chad Butler · ·
WP-Members 3.1.7 will be released Monday evening, April 3. There are some great improvements in the plugin that I am excited about, but if you are an existing user, there are some significant changes you should be aware of before blindly updating.
Note that there are no database changes updating to 3.1.7 from any flavor of 3.1. So you can roll back to the previous version if necessary. Continue Reading →
The Download Protect extension allows you to load files such as images, documents, etc to a protected directory that requires the user to be logged in to access.
This extension is available with the WP-Members Pro Bundle, WP-Members Lifetime Support, or is also available individually.
When you install the extension, it will add a “Downloads” tab to the WP-Members admin area. This tab is for managing the extension’s settings.
User IDs to exclude
This setting allows you to identify user IDs that you want to exclude from download stats tracking. Values should be the numeric ID of the user and all IDs should be separated by commas (do NOT use commas in IDs that are in the thousans; i.e. 14567 should not have a comma in it).
Set Error Page Location
This is a page you need to create to handle any errors, such as a non-logged in user attempting to download, or if something goes wrong with the download.
The plugin adds a menu item for uploading files. This is found under Media > Download Protect
This screen will give you a table of any media files you have uploaded to the protected download directory. This table includes link information (download links are by key and not by file name) for each file, and also allows you to edit any files should an uploaded file need to be updated.
Under Dashboard > Download Tracking is a screen that allows you to track what files have been downloaded by what users. The main screen is a list of all downloads and shows the date, the user, the file information (title and file name), the page they click on, and the user’s IP address.
This screen allows you to filter by user and by file so you can view more specific information. You can filter by:
Additionally, a truncated version of this table is included on the admin user profile page for each user showing the last 5 downloads (this value can be filtered to show more or less) with a link back to the main tracking page to show all downloads for that user.
Download the zip package from the downloads page. You can install this via the WP admin by going to Plugins > Add New and selecting Upload.
Once installed, the first thing you want to do is create an error page. This page is where a user will be directed in the event of an error when downloading (such as if a user is not logged in). On this page, place the following shortcode:
[wpmem_dp_error]
Once this page is created, go to Settings > WP-Members and option the Downloads tab. Use the selector for “Set Error Page Location” to select the page you create for download errors.
If you have any users you want to exclude from download tracking, enter their IDs separated by commas into “User IDs to exclude”.
Save your settings.
Now you are ready to upload some files. Go to Media > Download Protect and click “Add New”. This will give you a dialog to upload a file. Give the file a title (whatever identifies it to you) and click “Choose File” to open a file selector. Once the file is selected, click “Upload File”.
You can also edit or delete files from this list. To edit or delete a file, mouse over the file name and click the appropriate link from the hover menu.
Editing a file gives you the option to upload a new version of the file and/or change the file’s title. Note that none of the file’s information changes – specifically, the file’s identifying key. So any changes will be tracked in the statistics as the same as the previous file. If your new version needs to be tracked separately, it should be loaded as a new file.
Note that the download link is dependent upon the file’s key. So if you edit a file, you do not need to change the key. If you delete and/or replace, you’ll need to either edit your download links or remove them.
Once files have been loaded you can create links for your users to download. The list of files offers two options. First it gives you the file’s direct link. This can be used in the WP post editor when creating a link. Alternatively, it gives you a shortcode that will generate a download link using the file information. Either can be used.
Once files are loaded and some have been downloaded, you can view download statistics on the Dashboard > Download Tracking screen.
This extension is available with the WP-Members Pro Bundle, WP-Members Lifetime Support, or is also available individually.
Ready to get started?