• Skip to primary navigation
  • Skip to main content

RocketGeek

Home of WP-Members, The Original WordPress Membership Plugin

  • WordPress Plugins
    • WP-Members
      • FAQs
      • Quick Start
      • Documentation
      • Extensions
    • Advanced Options
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Download Protect
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Invite Codes
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • MailChimp Integration
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • PayPal Subscriptions
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Salesforce Web-to-Lead
    • Security
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Text Editor
      • Purchase the Plugin
      • Get the Pro Bundle
    • User List
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • User Tracking
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Memberships for WooCommerce
    • WordPass
  • Blog
    • Basics
    • Tips and Tricks
    • Filters
    • Actions
    • Code Snippets
    • Shortcodes
    • Design
    • Release Announcements
  • Store
    • Cart
    • Checkout
  • Contact
  • Log In
  • Show Search
Hide Search
Home » Search for "short code"

Search Results for: short code

wpmem_profile_url()

Description

This function returns the user profile page url (if one is set in the main options tab).

The function does not echo output.  Since it returns a string, this can be used for comparisons (to see if the user is actually on the user profile page), to output a link by echoing the result, or to redirect to the user profile page.  These are just a few examples.

Parameters

$a
(string)(optional) The WP-Members action variable, generally used to display the profile page forgot password dialog (‘pwdreset’).

Return Values

(string) The URL of the user profile page.

Examples

Create a link to the user profile page:

Use wpmem_current_url() to compare the current page:

Changelog

Introduced in version 3.1.1

Source

wpmem_profile_url() is located in /includes/api/api.php

wpmem_login_url()

Description

This function returns the login page url (if one is set in the main options tab).

The function does not echo output.  Since it returns a string, this can be used for comparisons (to see if the user is actually on the login page), to output a link by echoing the result, or to redirect to the login page.  These are just a few examples.

Return Values

(string) The URL of the login page.

Examples

Create a link to the login page:

Use wpmem_current_url() to compare the current page:

Changelog

Introduced in version 3.1.1

Source

wpmem_login_url() is located in /includes/api/api.php.

API Functions

WP-Members has several functions that can be used for customizing how your install works and operates.  These can be used in conjunction with the various filter and action hooks as well as shortcodes.

Form Pages and URLs

  • wpmem_redirect_to_login() – redirects content to the login page (if one is set).
  • wpmem_is_blocked() – checks if content is blocked or not.
  • wpmem_is_hidden() – checks if a post is marked as hidden.
  • wpmem_get_block_setting() – returns the block setting value for a post.
  • wpmem_login_url() – returns the login page URLas set in the plugin’s settings.
  • wpmem_register_url() – returns the register page URLas set in the plugin’s settings.
  • wpmem_profile_url() – returns the user profile page URLas set in the plugin’s settings.
  • wpmem_pwd_reset_url()
  • wpmem_forgot_username_url()
  • wpmem_user_pages() – returns an array of login, register, and profile page urls.
  • wpmem_current_url() – returns the current page URL.
  • wpmem_current_post_id() – returns the post ID for the current URL.
  • wpmem_is_reg_page() – checks the value of the wpmem_reg_page hidden field to validate what page the registration is occurring on.
  • wpmem_logout_link() – returns the URL used to log a user out.

Forms

  • wpmem_form_field() – creates a form field.
  • wpmem_form_label() – creates a field label.
  • wpmem_fields() – gets the form fields settings array.
  • wpmem_login_form()
  • wpmem_wp_login_form()
  • wpmem_register_form()
  • wpmem_change_password_form()
  • wpmem_reset_password_form()
  • wpmem_forgot_username_form()
  • wpmem_sanitize_class()
  • wpmem_sanitize_array()
  • wpmem_sanitize_field()
  • wpmem_form_nonce()
  • WP_Members_Captcha
  • wpmem_field_display_value()
  • wpmem_checkbox_field_display()
  • wpmem_select_field_display()

Dialogs and Emails

  • wpmem_gettext() – returns a requested string from the get_text function.
  • wpmem_display_message() – displays a requested dialog.
  • wpmem_use_custom_dialog() – uses a custom message dialog.
  • wpmem_add_custom_dialog() – adds a custom message dialog.
  • wpmem_add_custom_email() – adds a custom email message.
  • wpmem_login_status() – displays a user’s login status.
  • wpmem_loginout() – creates a login/logout link.
  • wpmem_mail_from()
  • wpmem_mail_from_name()
  • wpmem_email_to_user()
  • wpmem_notify_admin()
  • wpmem_gettext()

User Functions

  • wpmem_is_user() – returns boolean (true|false) to check if a user is a WP user.
  • wpmem_get_user_id() – returns a user ID from a username or email.
  • wpmem_get_user_obj() – returns a user object from a user ID, username, or email.
  • wpmem_get_user_role() – returns the user’s current role as an array, false if no role.
  • wpmem_user_has_role() – checks if a user has a specific role.
  • wpmem_get_user_meta() – functions exactly like WP’s get_user_meta(), but without the need for $single (always returns a string).
  • wpmem_get_user_meta_checkbox() – returns a user’s saved result for a specified checkbox field.
  • wpmem_get_user_meta_select() – returns a user’s saved result for a specified select (dropdown) field.
  • wpmem_get_user_meta_radio() – returns a user’s saved result for a specified radio field.
  • wpmem_get_user_meta_multi() – returns a user’s saved result for a specified multiple checkbox or multiple select field as a string.
  • wpmem_user_has_meta() – checks if a user has a given meta value.
  • wpmem_is_user_activated() – checks if the current or requested user is activated.
  • wpmem_user_data() – returns an array of the user’s registration data.
  • wpmem_update_user_role() – updates a user’s role.
  • wpmem_user_has_access() – checks if a user can access a restricted post.
  • wpmem_user_is_current() – similar to wpmem_user_has_access(), but specifically checks expiration.
  • wpmem_get_user_expiration() – gets a user’s expiration date for a specified membership.
  • wpmem_set_user_membership() – assigns product access to a user.
  • wpmem_remove_user_product() – removes product access from a user.
  • wpmem_get_user_products() – gets all memberships for a user.
  • wpmem_set_as_logged_in() – sets a user as logged in.
  • wpmem_login() – logs the user in using wp_signon().
  • wpmem_logout() – logs the user out, destroy session.
  • wpmem_create_membership_number() – creates a membership number.
  • wpmem_activate_user() – sets activation flag (for moderated registration).
  • wpmem_deactivate_user() – sets activation flag to 0.
  • wpmem_set_user_status() – sets the WP user_status value according to activated/deactivated.
  • wpmem_get_user_ip() – gets the current user’s IP address.
  • wpmem_export_users()
  • wpmem_get_users_by_meta()
  • wpmem_get_pending_users()
  • wpmem_get_activated_users()
  • wpmem_get_deactivated_users()
  • wpmem_create_username_from_email() – creates a username value from the provded email address.

Memberships

  • wpmem_get_membership_post_list()
  • wpmem_get_post_memberships()
  • wpmem_get_access_message()
  • wpmem_get_memberships()
  • wpmem_get_memberships_ids()
  • wpmem_get_membership_id()
  • wpmem_get_membership_name()
  • wpmem_get_membership_slug()
  • wpmem_get_membership_meta()
  • wpmem_add_membership_to_post()
  • wpmem_add_membership_to_posts()
  • wpmem_create_membership()

Utilities

  • wpmem_get() – utility to check posted variables and query strings.
  • wpmem_securify() – filters the main content variable.
  • wpmem_do_excerpt()
  • wpmem_get_excluded_meta()
  • wpmem_use_ssl() – checks if ssl is being used and returns https:// or http:// accordingly.
  • wpmem_force_ssl() – forces a given URL to use ssl (https://).
  • wpmem_write_log()
  • wpmem_array_insert() – inserts array items at specific point in an array.
  • wpmem_load_dropins() – loads dropin code snippets.
  • wpmem_format_date() – formats a given date.
  • wpmem_do_shortcode() – executes a given shortcode (any shortcode, not just WP-Members) without running the full shortcode regex.
  • wpmem_get_sub_str()
  • wpmem_texturize()
  • wpmem_format_date()
  • wpmem_user_sets_password() – checks if a password field is part of registration.
  • wpmem_maybe_unserialize()
  • wpmem_get_suffix()
  • wpmem_get_hidden_posts()
  • wpmem_update_hidden_posts()
  • wpmem_is_rest()

Extension API Functions

MailChimp Integration

  • wpmem_mc_get_list_member() – retreives subscriber data from the MailChimp API.
  • wpmem_mc_process_user() – subscribe, update, unsubscribe, or delete a user from the list.

WP-Members 3.1.1

Chad Butler · May 18, 2016 ·

This article is provided free. Find out how you can get full access to premium content, including how-to articles and support forums, as well as priority email support and member exclusive plugin extensions..

 

WP-Members 3.1.1 is primarily a feature release continuing development objectives from the 3.1 project.

Get the plugin here.

Continue Reading →

wpmem_user_upload_dir

Description

Allows you to filter the settings for the user upload directory when using a file or image upload field.

The default directory will be /wpmembers/user_files/{user id}/ in your main uploads directory (usually /wp-content/uploads/). This is not secure from random sweeps of your possible directories. If uploaded files are more sensitive/personal in nature, consider other options such as obfuscation of the directory names by using randomized values. The examples below give some instruction on how to do this using the wpmem_user_upload_dir filter.

Parameters

$args
(array) (required) An array of arguments that make up the user upload directory.

Defaults:

$args = array(
    'user_id'   => $user_id,
    'wpmem_dir' => 'wpmembers/',
    'user_dir'  => 'user_files/' . $user_id,
);

Usage

This filter can be used to make changes to the directory a user uploaded file will be stored in. One of the parameters in the array is the $user_id so you can change directories based on the user ID. The sub directories are option in a sense, but one is not used, you must return the array key with an empty value.

The wpmem_dir subdirectory should have a trailing slash, but not leading slash (i.e. $args['wpmem_dir'] should be “directory_name/” not “/directory_name”). The user_dir subdirctory should likewise not contain a leading slash.  The final directory in the user_dir subdirectory should not have a trailing slash ( i.e. $args['user_dir'] should be “user_dir/some_directory/someother_sub” but not “/user_dir/some_directory/someother_sub/”)

/**
 * This example makes a completely custom path for 
 * user file uploads based on the specific user ID.
 */
add_filter( 'wpmem_user_upload_dir', function( $args ) {
  
    // Change default directory if user ID is "10"
    if ( 10 == $args['user_id'] ) {
        $args['wpmem_dir'] = 'special_dir/',
        $args['user_dir'] = 'special_sub'
    }
    
    // Make sure to return $args.
    return $args;
});

If you wanted to create user upload directories that obfuscate the directory name by using a hash value, you could consider the following use of the wpmem_user_upload_dir filter:

/**
 * Add a random hash to the user upload directory.
 * 
 * Change the default name of the user upload directory.
 * This example completely removes the user ID value from the
 * directory name, leaving it as a completely random string.
 * 
 * Change $hash_len to set the length. Example creates a random
 * string 36 characters long.
 */
add_filter( 'wpmem_user_upload_dir', function( $args ) {
    
    // How long of a hash?
    $hash_len = 36;
    
    // Check if user already has a directory hash.
    $hash = get_user_meta( $args['user_id'], 'wpmem_file_dir_hash', true );
    if ( ! $hash ) {        
        /*
         * If there is no existing hash, we need to create one.
         * 
         * To make sure it is unique without having to do a for/while loop
         * while checking the db, we can use the user ID in the string.
         * Since the random hash is already long, inserting the user ID
         * does not degrade the randomness.  Theoretically, one could just
         * add the user ID without this step, but I like to have everything
         * being the same length so that a one digit user ID results in the 
         * same directory name length as a four digit user ID.
         *
         * This example makes it user ID + hash.  For example, where the 
         * user ID is "234", the resulting direcotry would be like this:
         * 
         *     234LXd2B8SE31u19TAS0SnwQW6ji
         * 
         * For ultimate randomness in this example, consider switching to
         * add the user ID to the end rather than the beginning.  I did it
         * at the beginning to allow a user with file system access to be
         * able to browse the directory by user ID if they understood the
         * directory name construction being done here.
         */
        $uid_len = strlen( $args['user_id'] );
        $hash = $args['user_id'] . wp_generate_password( ($hash_len-$uid_len), false, false );
        
        update_user_meta( $args['user_id'], 'wpmem_file_dir_hash', $hash );
    }
    
    $args['user_dir'] = $hash;
    
    return $args;
});

Changelog

Added in version 3.1.0

Source

wpmem_user_upload_dir is located in includes/class-wp-members-forms.php

  • « Go to Previous Page
  • Page 1
  • Interim pages omitted …
  • Page 31
  • Page 32
  • Page 33
  • Page 34
  • Page 35
  • Interim pages omitted …
  • Page 53
  • Go to Next Page »

Ready to get started?

Join Today!

© 2025 · butlerblog.com · RocketGeek is built using WordPress, WP-Members, and the Genesis Framework

  • butlerblog.com
  • WP-Members Support Subscription
  • Terms of Service
  • Privacy Policy
  • Refund Policy