WP-Members 3.1.6 has quite a few updates, some fixes, and some new features. There are some new API functions, some new action hooks, and a lot of code improvements.
The version 3.1.6 release candidate can be downloaded from Github for testing.
Main Object Changes and Custom Fields Settings Array
This version shifts some heavy lifting from the plugin’s initialization function to the class constructor. In layman’s terms, it moves things where they should be. In doing this, I also made some adjustments to the process that tests for proper plugin installation, which makes things more multi-site friendly.
Also in this version, the new fields settings array is now used throughout the plugin. So all use of numeric array keys are gone throughout. Using the new associative keys is much more intuitive. Even as the object loads the new settings, it keeps numeric keys in place for legacy purposes. But keep in mind, any customizations that retrieve the fields settings directly from the database (with get_option( ‘wpmembers_fields’ )) or from the object $wpmem->fields should be replaced with the API function wpmem_fields().
This release has some new API functions and some improvements to some others.
- wpmem_loginout() – This function works much like the newly introduced [wpmem_loginout] shortcode. In fact, it is the same function repackaged in the API (which the shortcode now uses). It will generate a login link or a logout link depending on the user’s login state. It has some arguments that it can accept which can change the default link text, add a redirect, and print the result to the screen.
- wpmem_array_insert() – This is a great new utility function in the API for adding an array element to an existing array. You can use it to add a new element before or after a given location (array key) in the existing array. Great for filter functions that handle arrays – no more slicing and reassembling arrays the messy way. (I’ve already started using this one A LOT in my own customizations.)
- wpmem_user_has_role() – This function now can check not only for a single role (passed as a string), but can check an array of roles to see if the user has a role that is one of several.
- wpmem_fields() – This function is now the primary loader for the WP-Members custom fields. Custom scripts should no longer get the fields array directly (using get_option(‘wpmembers_fields’) or $wpmem->fields ). As noted above, the plugin object now uses wpmem_fields() which will return the fields array (if loaded) and if not loaded, will load it. The fields array loaded through wpmem_fields() will contain the new fields array as well as legacy array values (numeric).
The Auto Excerpt has some updates including a very cool new feature.
First, there is the addition of custom “read more” text in the settings. Previously, the WP default text was used unless you filtered the value. However, almost every theme uses its own custom “read more” text instead of the WP default (which was simply (more…)). Now you can easily drop in whatever text your theme is using (or whatever else you want) for your auto excerpt read more link.
The other update here fixes an issue that is the result of the shift to the previously introduced wp_trim_words() function. Changing to this function caused a problem if the text of a post was less than the number of words set for the auto excerpt. In most cases, it would be unlikely that this problem would be noticed, but it is possible in other situations. For example, if you had an auto excerpt set at 150 words and a specific post was only 100, then the wp_trim_words() process would leave off the “read more” link as the post was too short. This update corrects that so that the “read more” link is always added to the auto excerpt regardless of the length of the excerpt (basically the way it behaved prior to the switch to wp_trim_words()).
In the previous release, there was an update to the [wpmem_field] shortcode to allow for displaying select, multiple select, multiple checkbox, and radio fields in different ways. It could either display the raw data or the display labels. Unfortunately, there was a problem with the handling of the multiple select and the multiple checkbox output (which is actually OK, because handling them wasn’t ever actually done prior to this update). This version fixes this issue and will now display either the raw or the display value data for these two field types.
Some actions were moved in the order of where they fire. This move shouldn’t affect anyone who is the typical user of this plugin because these were never fully documented or discussed. The following were moved from after the associated process to now fire before:
New action hooks were added after the associated processes for each of these with names that reflect the fact that they come after the process:
Admin Panel Improvements
- Updated dropdowns for handling the login, register, and user profile page selection to display the proper preselected value when using ssl (https://) and no value is selected.
- Changed the term “Option Name” in the Fields tab to “Meta Key” for clarity. The HTML option name of fields is stored as a user meta field where this value is the meta key. So this should help for some users to connect the dots when customizing or accessing db data.
- Marked required custom field properties as required in Add/Edit Field dialogs (i.e. Field Label, Meta Key, and Stored value when checked). This should make it more clear which values absolutely require an entry when creating custom fields.
- reCAPTCHA version 1 is no longer supported by Google. This version no longer provides reCAPTCHA version 1 as a selectable option for new installs. If you have an existing install that has reCAPTCHA version 1 selected, it will remain supported by the plugin, but once you change to another CAPTCHA option, this will no longer be available. It is recommended that users of version 1 change to one of the other CAPTCHA options.
- Improved support for WooCommerce registration. WP-Members custom fields added to the WooCommerce form that display on the My Account page should now be handled like any other custom field.
- WP-Members logout function updated to use wp_destroy_current_session(). This should lead to improved logout handling.
- Fields settings now include an option for placeholders. While this won’t be implemented as an option yet, this lays the backend groundwork for adding this as a selectable feature in a future release.
- Localization of some previously untranslated strings.
- “Remember Me” checkbox label in the login form now wrapped with HTML label tag.