Filter Hooks in MemberPress

Here you can find the list of the most common filter hooks divided into sections that you can find and use in MemberPress.

If you want to learn more about hooks please check out Actions and Filters in MemberPress article.

Rules

Signup

Admin

Account Page

Login

Emails

Miscellaneous

mepr-pre-run-rule-content

Description

Add this filter to allow external resources to control whether to show or hide this content if the resource sets the filter to FALSE then it will not be protected
It is used inside the function to replace content for unauthorized visitors if redirect_on_unauthorized is not selected in MeprOptions.

Parameters

$value Boolean
$current_post WP_Post
$uri String

Example

Unprotect MemberPress posts if they have a certain category

add_filter('mepr-pre-run-rule-content', 'mepr_override_content_protection', 11, 3);
function mepr_override_content_protection($protect, $post, $uri) {
    if(has_category('category_slug_here', $post)) { $protect = false; }
    return $protect;
}

mepr-pre-run-rule-redirection

Description

Add this filter to allow external resources to control whether to redirect away from this content. If the resource sets the filter to FALSE then no redirect will occur
It is used inside the function to redirect unauthorized visitors if redirect_on_unauthorized is selected in MeprOptions or if we're protecting a WP controlled-URI

Parameters

$protect Boolean
$uri String   
$delim String

Example

Unprotect MemberPress posts if they have a certain category

add_filter('mepr-pre-run-rule-redirection', 'mepr_override_redirection_protection', 11, 3);
function mepr_override_redirection_protection($protect, $uri, $delim) {
    global $post; //$post - may not be availble here if not using "template_redirect" as the redirect action in MemberPress Options
    if(!isset($post) || !($post instanceof WP_Post)) { return $protect; }
    $user = MeprUtils::get_currentuserinfo();
    if($user === false) { return $protect; }

    $registration_date = strtotime(MeprUser::get_user_registration_date($user->ID)) - MeprUtils::months(1);
    $post_date = strtotime($post->post_date);
    $active_product_subscriptions = $user->active_product_subscriptions();
    if(!empty($active_product_subscriptions) && $post_date >= $registration_date) {
        return false; // Don't protect the content
    }
    return $protect;
}

mepr-last-chance-to-block-content

Description

The user is allowed to see this content, but it gives developers one last chance to block it if necessary. It will be very helpful for magazine style membership sites. It returns TRUE here to block the content from this user.
It is used inside the function to replace content for unauthorized visitors if redirect_on_unauthorized is not selected in MeprOptions.

Parameters

$value Boolean
$current_post WP_Post
$uri String

mepr-validate-signup

Description

It is used to validate signup fields

Parameters

$errors Array

Example

Limit Signups to USA only

function limit_signups_to_one_country($errors) {
  if(!isset($_POST['mepr-address-country']) || $_POST['mepr-address-country'] != 'US') {
    $errors[] = 'Sorry, signups are currently limited to USA only.';
  }

  return $errors;
}
add_filter('mepr-validate-signup', 'limit_signups_to_one_country');

mepr-signup-styles

Description

Add custom style to signup page

Parameters

$prereqs Array

Example

function mepr_signup_styles($prereqs) {
  // Do what you need
  return $prereqs;
}
add_filter('mepr-signup-styles', 'mepr_signup_styles');

mepr-signup-scripts

Description

Add custom script to signup or account page

Parameters

$prereqs Array
$is_product_page Boolean
$is_account_page Boolean

Example

function mepr_signup_scripts($prereqs, $is_product_page, $is_account_page) {
  // Do what you need
  return $prereqs;
}
add_filter('mepr-signup-scripts', 'mepr_signup_scripts', 10, 3);

function validate_invisible_recaptcha_mepr_signup($errors) { $is_valid = apply_filters('google_invre_is_valid_request_filter', true); if(!$is_valid) { $errors[] = "Failed Captcha"; } return $errors; } add_filter('mepr-validate-signup', 'validate_invisible_recaptcha_mepr_signup');

mepr-signup-checkout-url

Description

It is used to change signup checkout URL

Parameters

$url String
$txn Transaction object

Example

function mepr_signup_checkout_url($url, $txn) {
  // Do what you need
  return $url;
}
add_filter('mepr-signup-checkout-url', 'mepr_signup_checkout_url', 11, 2);

mepr_render_custom_fields

Description

Re-order custom fields on the signup page

Parameters

$custom_fields Array

Example

function moveElement(&$array, $a, $b) {
  $out = array_splice($array, $a, 1);
  array_splice($array, $b, 0, $out);
}
function mepr_render_custom_fields_fn($custom_fields) {
  moveElement($custom_fields, 5, 2);
  return $custom_fields;
}
add_filter('mepr_render_custom_fields', 'mepr_render_custom_fields_fn');

mepr-admin-members-cols

Description

It allows you to add a custom column to MemberPress → Members page.

Parameters

$cols Array

Example

function mepr_admin_members_cols($cols) {
  // Do what you need
  return $cols;
}
add_filter('mepr-admin-members-cols', 'mepr_admin_members_cols');

mepr-admin-subscriptions-cols

Description

Add column to the Admin site

Parameters

$cols Array
$prefix String
$lifetime String

Example

function mepr_add_admin_subscriptions_cols($cols, $prefix, $lifetime) {
  $cols[$prefix.'site'] = 'Site';
  return $cols;
}
 add_filter('mepr-admin-subscriptions-cols', 'mepr_add_admin_subscriptions_cols', 10, 3);

mepr_user_subscriptions_query_cols

Description

It is used to fetch additional columns from user's subscription

Parameters

$cols Array

Example

function mepr_user_subscriptions_query_cols($cols) {
  //Do what you need
  return $cols;
}
add_filter('mepr_user_subscriptions_query_cols', 'mepr_user_subscriptions_query_cols');

mepr-admin-transactions-cols

Description

Add column to the Admin Transactions table

Parameters

$cols Array

Example

function mepr_add_admin_transactions_cols($cols) {
  // Add your column here
  return $cols;
}
add_filter('mepr-admin-transactions-cols', 'mepr_add_admin_transactions_cols');

mepr-admin-transactions-sortable-cols

Description

Add sortable column to the Admin Transactions table

Parameters

$cols Array

Example

function mepr_admin_transactions_sortable_cols($cols) {
  // Add your column here
  return $cols;
}
add_filter('mepr_admin_transactions_sortable_cols', 'mepr-admin-transactions-sortable-cols');

mepr_nonrecurring_subscriptions_table_joins

Description

It is used to modify join query to fetch from non-recurring subscriptions table

Parameters

$joins Array

Example

function mepr_nonrecurring_subscriptions_table_joins($joins) {
  //Do what you need
  return $joins;
}
add_filter('mepr_nonrecurring_subscriptions_table_joins', 'mepr_nonrecurring_subscriptions_table_joins');

mepr_nonrecurring_subscriptions_table_cols

Description

It is used to modify columns fetched from non-recurring subscriptions table

Parameters

$cols Array

Example

function mepr_nonrecurring_subscriptions_table_cols($cols) {
  //Do what you need
  return $cols;
}
add_filter('mepr_nonrecurring_subscriptions_table_cols', 'mepr_nonrecurring_subscriptions_table_cols');

mepr_recurring_subscriptions_table_joins

Description

It is used to modify join query to fetch from recurring subscriptions table

Parameters

$joins Array

Example

function mepr_recurring_subscriptions_table_joins($joins) {
  //Do what you need
  return $joins;
}
add_filter('mepr_recurring_subscriptions_table_joins', 'mepr_recurring_subscriptions_table_joins');

mepr_recurring_subscriptions_table_cols

Description

It is used to modify columns fetched from subscriptions table

Parameters

$cols Array

Example

function mepr_recurring_subscriptions_table_cols($cols) {
  //Do what you need
  return $cols;
}
add_filter('mepr_recurring_subscriptions_table_cols', 'mepr_recurring_subscriptions_table_cols');

mepr_import_subscription_pre_store

Description

It is used to modify subscription in Importer before it is stored

Parameters

$sub Subscription object

Example

function mepr_import_subscription_pre_store($sub_id) {
  //Do what you need
}
add_filter('mepr_import_subscription_pre_store', 'mepr_import_subscription_pre_store');

mepr_import_subscription_post_store

Description

It is used to modify subscription in Importer after it is stored

Parameters

$sub_id Integer

Example

function mepr_import_subscription_post_store($sub_id) {
  //Do what you need
}
add_filter('mepr_import_subscription_post_store', 'mepr_import_subscription_post_store');

mepr_user_subscriptions_customize_subscription

Description

It is used to filter through the subscriptions. It is called inside foreach loop.

Parameters

$sub Subscription or Transaction object
$row Subscription for each item in the loop
$user User object

Example

function mepr_customize_subscription($sub, $row, $user) {
  //Do what you need
}
add_filter('mepr_user_subscriptions_customize_subscription', 'mepr_customize_subscription', 10, 3);

mepr-account-welcome-message

Description

Change welcome message on the Account page

Parameters

$message String
$user User Object

Example

function mepr_account_welcome_message($message, $user) {
  // Do what you need
  return message;
}
 add_filter('mepr-account-welcome-message', 'mepr_account_welcome_message', 10, 2);

mepr-user-message

Description

Change user message on the Account page

Parameters

$message String
$user User Object

Example

function mepr_account_user_message($message, $user) {
  // Do what you need
  return message;
}
add_filter('mepr-user-message', 'mepr_account_user_message');

Description

Change the link of the Home tab of the Account page

Example

function mepr_account_nav_home_link() {
  // Return your link
}
 add_filter('mepr-account-nav-home-link', 'mepr_account_nav_home_link');

Description

Change the link of the Subscriptions tab of the Account page

Example

function mepr_account_nav_subscriptions_link() {
  // Return your link
}
 add_filter('mepr-account-nav-subscriptions-link', 'mepr_account_nav_subscriptions_link');

Description

Change the link of the Payments tab of the Account page

Example

function mepr_account_nav_payments_link() {
  // Return your link
}
 add_filter('mepr-account-nav-payments-link', 'mepr_account_nav_payments_link');

mepr-account-nav-home-label

Description

Change the label of the Subscriptions tab of the Account page

Example

function mepr_account_nav_home_label() {
  // Return a new label
}
 add_filter('mepr-account-nav-home-label', 'mepr_account_nav_home_label');

mepr-account-nav-subscriptions-label

Description

Change the label of the Subscriptions tab of the Account page and the Subscriptions label in the message that appears on this page if there are any issues with user subscriptions

Example

function mepr_account_nav_subscriptions_label() {
  // Return a new label
}
 add_filter('mepr-account-nav-subscriptions-label', 'mepr_account_nav_subscriptions_label');

mepr-account-nav-payments-label

Description

Change the label of the Payments tab of the Account page

Example

function mepr_account_nav_payments_label() {
  // Return a new label
}
 add_filter('mepr-account-nav-payments-label', 'mepr_account_nav_payments_label');

mepr-account-payment-product-name

Description

Change Membersip Title in the Membership column. It is in the Payments tab of the Account page

Parameters

$membership_title String
$txn Transaction Object

Example

function mepr_account_payment_product_name($membership_title, $txn) {
  // Do what you need
  return $membership_title;
}
add_filter('mepr-account-payment-product-name', 'mepr_account_payment_product_name');

mepr-account-subscr-product-name

Description

Change Membersip Title in the Membership column. It is in the Subscriptions tab of the Account page

Parameters

$membership_title String
$txn Transaction Object

Example

function mepr_account_subscr_product_name($membership_title, $txn) {
  // Do what you need
  return $membership_title;
}
add_filter('mepr-account-subscr-product-name', 'mepr_account_subscr_product_name');

mepr-validate-account

Description

It is used to validate fields on the Account page

Parameters

$errors Array
$user User object

Example

Validate Display Name field to MemberPresss account page

function mpdn_validate_on_account($errors, $user) {
  if(!isset($_POST['mepr_user_display_name']) || empty($_POST['mepr_user_display_name'])) {
    $errors[] = "You must enter a Public Display Name";
    return $errors;
  }

  $display_name = stripslashes($_POST['mepr_user_display_name']);
  $new_email    = stripslashes($_POST['user_email']);
  $old_email    = $user->user_email;
  $username     = $user->user_login;

  if($display_name == $new_email || $display_name == $old_email) {
    $errors[] = "Your Public Display Name cannot be the same as your Email Address";
  }
  if($display_name == $username) {
    $errors[] = "Your Public Display Name cannot be the same as your Username";
  }

  return $errors;
}
add_filter('mepr-validate-account', 'mpdn_validate_on_account', 11, 2);

mepr-active-nav-tab

Description

Change navigation class of tabs on the Account page

Parameters

$class String
$tab String
$active_class String

Example

function mepr_active_nav_tab($class, $tab, $active_class) {
  // Do what you need
  return $class;
}
add_filter('mepr-active-nav-tab', 'mepr_active_nav_tab', 10, 3);

Description

Add content after Change Plan of Subscriptions tab of the Account page

Parameters

$html String
$txn Transaction Object

Example

function mepr_custom_upgrade_link_txn_fn($html, $txn) {
  // Do what you need
  return $html;
}
add_filter('mepr_custom_upgrade_link_txn', 'mepr_custom_upgrade_link_txn_fn', 10, 2);

mepr-login-redirect-url

Description

Change URL to redirect member after login. This redirect will be overwritten with per membership redirect URL settings

Parameters

$url String

Example

function mepr_login_redirect_url($url) {
  // Do what you need
  return $url;
}
add_filter('mepr-login-redirect-url', 'mepr_login_redirect_url');

mepr-process-login-redirect-url

Description

Change URL to redirect member after login. It replaces global and per membership Login URL settings

Parameters

$url String
$user User Object

Example

Redirect member to URL after login

function mepr_process_login_redirect_url_fn($url, $user) {
  $roles = $user->roles;
  if($roles && false !== array_search('author', $roles)) {
    $url = 'https://your_domain.com';
  }
  return $url;
}
add_filter('mepr-process-login-redirect-url', 'mepr_process_login_redirect_url_fn', 11, 2);

mepr-login-uname-or-email-str

Description

Change Username or E-mail label on the Login page that is displaying when "Members must use their email address for their Username" option is enabled

Example

function mepr_login_uname_or_email_str() {
  return 'New Username or E-mail Label';
}
add_filter('mepr-login-uname-or-email-str', 'mepr_login_uname_or_email_str');

mepr-login-uname-str

Description

Change Username label on the Login page

Example

function mepr_login_uname_str() {
  return 'New Username Label';
}
add_filter('mepr-login-uname-str', 'mepr_login_uname_str');

Description

Change Login link text in unauthorized message

Example

function mepr-unauthorized-login-link-text() {
  return 'New Login Link';
}
add_filter('mepr-unauthorized-login-link-text', 'mepr-unauthorized-login-link-text');

mepr-wp-mail-recipients

Description

Change email recipients

Parameters

$recipients Array
$subject String
$message String
$headers Array

Example

function mepr_wp_mail_recipients($recipients, $subject, $message, $headers) {
  // Do what you need
  return $recipients;
}
add_filter('mepr-wp-mail-recipients', 'mepr_wp_mail_recipients', 10, 4);

mepr-wp-mail-subject

Description

Change email subject

Parameters

$subject String
$recipients Array
$message String
$headers Array

Example

function mepr_wp_mail_subject($subject, $recipients, $message, $headers) {
  // Do what you need
  return $subject;
}
add_filter('mepr-wp-mail-subject', 'mepr_wp_mail_subject', 10, 4);

mepr-wp-mail-message

Description

Change email message

Parameters

$message String
$recipients Array
$subject String
$headers Array

Example

function mepr_wp_mail_message($message, $recipients, $subject, $headers) {
  // Do what you need
  return $message;
}
add_filter('mepr-wp-mail-message', 'mepr_wp_mail_message', 10, 4);

mepr-wp-mail-headers

Description

Change email header

Parameters

$headers Array
$recipients Array
$subject String
$message String
$attachments Array

Example

Add CC to all emails

function mepr_wp_mail_headers($headers, $recipients, $subject, $message, $attachments) {
  $cc_email = sanitize_email('[email protected]');
  $headers[] = 'Cc: ' . $cc_email;
  return $headers;
}
add_filter('mepr-wp-mail-headers', 'mepr_wp_mail_headers', 10, 5);

mepr_reminder_email_params

Description

Modify values return from reminder email parameters

Parameters

$params Array
$reminder Reminder Object

Example

function mepr_reminder_email_params_fn($params, $reminder) {
  // Do what you need
  return $params;
}
add_filter('mepr_reminder_email_params', 'mepr_reminder_email_params_fn', 10, 2);

mepr_reminder_email_vars

Description

Modify reminder email parameters variables

Parameters

$vars Array
$reminder Reminder Object

Example

function mepr_reminder_email_vars_fn($vars, $reminder) {
  // Do what you need
  return $vars;
}
add_filter('mepr_reminder_email_vars', 'mepr_reminder_email_vars_fn', 10, 2);

mepr_subscription_email_params

Description

Modify values return from email parameters

Parameters

$params Array
$sub Subscription Object

Example

function mepr_subscription_email_params_fn($params, $sub) {
  // Do what you need
  return $params;
}
add_filter('mepr_subscription_email_params', 'mepr_subscription_email_params_fn', 10, 2);

mepr_subscription_email_vars

Description

Modify email parameters variables

Parameters

$vars Array

Example

function mepr_subscription_email_vars_fn($vars) {
  // Do what you need
  return $vars;
}
add_filter('mepr_subscription_email_vars', 'mepr_subscription_email_vars_fn');

mepr-hide-cpt-access-column

Description

Remove Access column in the Custom Post Types pages in dashboard

Parameters

$except Array of CPT' names

Example

function mepr_hide_cpt_access_column($except) {
  // Do what you need
  return $prereqs;
}
add_filter('mepr-hide-cpt-access-column', 'mepr_hide_cpt_access_column');

mepr_fetch_options

Description

It is used to filter fetched MemberPress options

Parameters

$options MemberPress Options Object

Example

Remove the State Field completely (it requires more code to function properly)

function trim_down_address_fields($options) {
  foreach($options->address_fields as $i => $o) {
    if($o->field_key == 'mepr-address-state') {
      unset($options->address_fields[$i]);
    }
  }

  return $options;
}
add_filter('mepr_fetch_options', 'trim_down_address_fields');

mepr_checkout_show_terms

Description

Show price terms in the Signup form

Parameters

$show_price Boolean

Example

Hide price terms on Signup pages

function mepr_checkout_show_terms_fn($show_price) {
  return false;
}
add_filter('mepr_checkout_show_terms', 'mepr_checkout_show_terms_fn');

Description

It is used to change MemberPress Cancel URL in Actions column of the Accout page

Parameters

$html String
$sub Subscription object

Example

Hijack MemberPress Cancel URL (it requires more code to function properly)

function cspf_custom_cancel_link($html, $sub) {
  ob_start();
  ?>
    <a href="?action=upsell&sub=<?php echo $sub->id; ?>">Cancel</a>
    <?php
  return ob_get_clean();
}
add_action('mepr_custom_cancel_link', 'cspf_custom_cancel_link', 10, 2);

mepr-currency-symbols

Description

Change the list of "Currency Symbol" in the MemberPress General settings

Parameters

$codes Array

Example

function mepr_currency_symbols($codes) {
  $new_code = array('৳');
  array_splice( $codes, 4, 0, $new_code );
  return $codes;
}
add_filter('mepr-currency-symbols', 'mepr_currency_symbols');

mepr-currency-codes

Description

Change the list of "Currency Code" in the MemberPress General settings

Parameters

$codes Array

Example

function mepr_currency_codes($codes) {
  $new_code = array('BDT');
  array_splice( $codes, 4, 0, $new_code );
  return $codes;
}
add_filter('mepr-currency-codes', 'mepr_currency_codes');

mepr-language-codes

Description

Change the list of "Language Code" in the MemberPress General settings

Parameters

$codes Array

Example

function mepr_language_codes($codes) {
  $new_code = array('BN');
  array_splice( $codes, 4, 0, $new_code );
  return $codes;
}
add_filter('mepr-language-codes', 'mepr_language_codes');

mepr_countries

Description

Change the list of countries in the singup page

Parameters

$countries Array
$prioritize_my_country Boolean

Example

Leave Germany as the only country in the dropdown list on the signup page

function mepr_countries_fn($countries, $prioritize_my_country) {
  return array(
    'DE' => _x('Germany', 'ui', 'memberpress')
  );
}
add_filter('mepr_countries', 'mepr_countries_fn');

mepr-jobs-config

Description

Change default WP Cron job configuration object

Parameters

$config Object

Example

function mepr_jobs_config($config) {
  $config['worker']['interval'] = MeprUtils::minutes(30);
  return (object)$config;
}
add_filter('mepr-jobs-config', 'mepr_jobs_config');

mepr-admin-capability

Description

Change default MemberPress capability to display MemberPress menu items

Parameters

$cap String

Example

function mepr_admin_capability($cap) {
  // Do what you need
  return $cap;
}
add_filter('mepr-admin-capability', 'mepr_admin_capability');

mepr_price_box_benefit

Description

Change item in the list of Group benefits

Parameters

$element String
$index Number

Example

function mepr_price_box_benefit_fn($element, $index) {
  // Do what you need
  return $element;
}
add_filter('mepr_price_box_benefit', 'mepr_price_box_benefit_fn', 10, 2);

mepr-group-css-classes-string

Description

Change class of the Group price box

Parameters

$classes String
$product Membership Object
$group Group Object
$preview Boolean

Example

function mepr_group_css_classes_string($classes, $product, $group, $preview) {
  // Do what you need
  return $classes;
}
add_filter('mepr-group-css-classes-string', 'mepr_group_css_classes_string', 10, 4);

mepr-group-page-item-output

Description

Change the Group box item

Parameters

$output String
$product Membership Object
$group Group Object
$preview Boolean

Example

function mepr_group_page_item_output($output, $product, $group, $preview) {
  // Do what you need
  return $output;
}
add_filter('mepr-group-page-item-output', 'mepr_group_page_item_output', 10, 4);

mepr_custom_thankyou_message

Description

Change custom Thank You page message

Parameters

$message String

Example

function mepr_custom_thankyou_message_fn($message) {
  // Do what you need
  return $message;
}
add_filter('mepr_custom_thankyou_message', 'mepr_custom_thankyou_message_fn');
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.