This code snippet is specifically for the User List extension, which many users use to implement a User Directory. The code snippet discussed here will demonstrate how to include on option in the registration form for users to “opt out” of being displayed in the directory.
Continue Reading →Search Results for: short code
wpmem_ul_profile_args
Description
This filter allows you to pass arguments to the User List profile function to override default values that are used in the layout. The wpmem_do_ul_profile function uses the wp_parse_args function to merge arguments passed through this filter with the following defaults:
$defaults = shortcode_atts( array( 'fields' => array(), // Default will contain an array of the defined profile fields. 'id' => $user_id, // Default will contain the current user ID. 'div' => true, 'div_id' => '', 'div_class' => 'field-name', 'span' => false, 'span_id' => '', 'span_class' => '', 'avatar' => '80', 'labels' => $this->settings['show_labels'], 'show_empty' => $this->settings['show_empty'], 'user_label_before' => '', 'user_label_after' => '', 'user_field_before' => '', 'user_field_after' => '', 'main_div_before' => '<div id="user-list-profile">', 'main_div_after' => '</div>', ), $atts, $tag );
Parameters
$defaults (array) (required) The defaults of for display of the profile (see description above)
$user_id (integer) (optional) The user ID of the user being displayed.
Example
Changelog
- Introduced in extension version 1.4
- 2.0.0 added $defaults parameter
- 2.0.1 added $user_id parameter
Source
wpmem_ul_profile_args is located in user-profile.php
Restrict content by user level
I have written code snippets before on how to restrict content by user level, but that particular code snippet is based on using categories as the user levels, with higher level users still being able to access lower level content. For example, Silver, Gold, and Platinum level users having access or not to categories of the same name.
But what if you have content that you need to block by level that is not necessarily in a category? Or what if you are using pages that need the same level of restriction.
Here is a code snippet that will allow you to assign a “level” to any content – post or page, and then assign a user level for the users. This example provides a working code snippet for applying a series of progressive levels (higher level users have access to lower level content). The example begins with three generically named levels, these can be renamed and expanded or contracted as needed.Continue Reading →
Request additional data fields on a specific page
This particular example is a generic tutorial for requesting additional data fields in the registration form on a specific page. Since these are fields that do not show up in the regular registration form, we need to also present the data to logged in users to add this data.
While conceptually this is not an overly complicated process, the practical implementation has quite a few steps, so I will try to explain each step in the process while giving that particular code snippet being discussed at that point.Continue Reading →
wpmem_exp_sc_expmsg
Description
This hook allows you to filter the message that is displayed to a user when they attempt to view content that is restricted by the subscription shortcode:
- [[wp-members status=sub]This is subscription content[/wp-members]]
- [wpmem_logged_in status=sub]This is subscription content[/wpmem_logged_in]
Parameters
$msg
(string) (required) A string containing the message.
Changelog
Introduced in version 0.1
Source
wpmem_exp_sc_expmsg is located in module.php