Additional menu

Get MemberPress today! Start getting paid for the content you create! Get MemberPress Now

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

Invoice

Miscellaneous

Courses

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

Example

//Block the post based on the post ID

function mepr_block_content($value, $current_post, $uri) {
  if($current_post->ID === 2) { // Blocks the post with ID 2. Adjust the ID to the ID of the post you need to block.
    return true;
  }

  return $value;
}
add_filter('mepr-last-chance-to-block-content', 'mepr_block_content', 10, 3);

mepr-rule-redirect-unauthorized-url

Description

Redirect unauthorized visitors to a different page instead of the global unauthorized page

Parameters

$redirect_url String
$delim String
$uri String

Example

//Redirect unauthorized visitors to the particular page

function mepr_single_redirect($redirect_url, $delim, $uri) {
  global $post;
  if($post->ID === 2) {
    $redirect_url = "https://your-domain.com/new-page{$delim}mepr-unauth-page={$post->ID}&redirect_to=".urlencode($uri);
  }
  return $redirect_url;
}

add_filter('mepr-rule-redirect-unauthorized-url', 'mepr_single_redirect', 10, 3);

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 the 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);

mepr-signup-checkout-url

Description

It is used to change the 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_product_access_string

Description

Change message displayed on the registration page when a user has already subscribed to this membership

Parameters

$prd Membership Object

Example

function mepr_custom_product_access_string($prd) {
  $echo = preg_replace('/you have already subscribed to this item/i', 'Custom message', $prd);
  $echo = preg_replace('/click here to access it/i', 'Custom text link', $echo);
  return $echo;
}

add_filter('mepr_product_access_string', 'mepr_custom_product_access_string');

mepr-stripe-elements-appearance

Description

Change default styling of Stripe fields

Parameters

$style Array

Example

//Change the text color of the Stripe fields to green

function mepr_change_stripe_text_color($style) {
$style['variables']['colorText'] = 'green';
return $style;
}

add_filter('mepr-stripe-elements-appearance', 'mepr_change_stripe_text_color');

mepr-stripe-form-hide-postal-code

Description

Remove postal code from Stripe field

Parameters

$hide Boolean

Example

function mepr_hide_post_code_stripe_elements($hide) {
  return true;
}

add_filter('mepr-stripe-form-hide-postal-code', 'mepr_hide_post_code_stripe_elements');

mepr-is-product-page

Description

Enqueue scripts for custom membership pages. It is needed if someone has a phone field issue with our scripts missing

Parameters

$return Boolean

$post Post Object

Example

function mepr_is_product_page($return, $post) {
  $custom_pages = array(2710);
  if(isset($post) && in_array($post->ID, $custom_pages)) {
    return true;
  }
  return $return;
}

add_filter('mepr-is-product-page', 'mepr_is_product_page', 10, 2);

mepr-product-url

Description

Set custom page with shortcode as membership page. That will update all links on the Account page, so they no longer point to the default registration page.

Parameters

$url String

$product Membership Object

$args Array

$modify_if_https Boolean

Example

function mepr_custom_membership_urls($url, $product, $args, $modify_if_https) {
  if($product->ID === 123) {
    $url = 'https://your-domain.com/professional-membership/';
  };
  if($product->ID === 456) {
    $url = 'https://your-domain.com/basic-membership/';
  };
  return $url;
}

add_filter('mepr-product-url', 'mepr_custom_membership_urls', 10, 4);

mepr_format_currency

Description

Change the way the price and currency on registration pages are displayed.

Parameters

$rstr String

$number Number

$show_symbol Boolean

Example

Add space between price and currency symbol

function mepr_format_currency_func($rstr, $number, $show_symbol) {
  $mepr_options = MeprOptions::fetch();
  return (string)MeprUtils::format_currency_float((float)$number, 2) . ' ' . $mepr_options->currency_symbol;
}

add_filter('mepr_format_currency', 'mepr_format_currency_func', 10, 3);

mepr-admin-members-cols

Description

It allows you to add a custom column to the Members page in the backend (Dashboard > MemberPress > Members).

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 the 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 a 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 the join query to fetch from the 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 the join query to fetch from the 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 the 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 subscriptions 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 subscriptions 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 the 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 the 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 the 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', 10, 2);

Description

Change the link of the Home tab on 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 on 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 on 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 on 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 the Membership 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', 10, 2);

mepr-account-subscr-product-name

Description

Change the Membership 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', 10, 2);

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 the 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 the Change Plan link on the 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-product-renewal-string

Description

Change the renewal price display string for a one-time payment. Note: This does not change the actual renewal price. 

Parameters

$renewal_str String

$product Membership Object

Example

//Change renewal price display string for membership with ID 123

function mepr_product_renewal_price($renewal_str, $product) {
  if($product->ID === 123) { // Adjust the ID on this line
  $renewal_str = ' (<strong>Special offer</strong> for renewal)';
}
return $renewal_str;
}

add_filter('mepr-product-renewal-string', 'mepr_product_renewal_price', 2, 10);

mepr_payments_per_page

Description

Change the number of payments displayed on the Account page

Example

function mepr_payments_per_page() {
  return 10;
}

add_filter('mepr_payments_per_page', 'mepr_payments_per_page');

mepr_is_account_page

Description

Add a custom account page so all MemberPress scripts are enqueued

Parameters

$is_account Boolean

$post Post Object

Example

function mepr_is_account_page_fn($is_account_page, $post) {
  if(is_page(123)) {
    return true;
  };
  return $is_account_page;
}

add_filter('mepr_is_account_page', 'mepr_is_account_page_fn', 10, 2);

mepr-account-action

Description

Display a specific section of the Account form on the custom page, using the following shortcode:

[mepr-account-form]

Parameters

$action String, for example, subscriptions, payments, or courses

Example

// Display the Subscriptions table from the Account page on the custom page. The mepr-account-form shortcode must be added to that custom page for the code snippet to work.

function mepr_account_action_fn($action) {
  if(is_page(2006) && !isset($_GET['action'])) {
    return 'subscriptions';
  };
  return $action;
}

add_filter('mepr-account-action', 'mepr_account_action_fn');

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 the after-login redirection URL. It replaces the 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 the Username or E-mail label on the Login page. This label is displayed when the Members must use their email address for their Username option is enabled in the MemberPress settings.

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 the 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 the label of the Login link within the 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-auto-login

Description

Control whether a new user is automatically logged in.

Parameters

$auto_login Boolean

$membership_id Membership Object

$mepr_user User Object

Example

function mepr_disable_auto_login($auto_login, $membership_id, $mepr_user) {
  return false;
}

add_filter('mepr-auto-login', 'mepr_disable_auto_login', 10, 3);

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('example@abc.com');
  $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 returned 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 returned 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-pdf-invoice-data

Description

Modify invoice parameters generated by PDF Invoice Add-on

Parameters

$invoice Invoice Object

$txn Transaction Object

Example

//Change the invoice's description

function mepr_change_invoice_desc($invoice, $txn) {
  $prd = $txn->product();
  $invoice['items'][0]['description'] = $prd->post_title;
  return $invoice;
}

add_filter('mepr-pdf-invoice-data', 'mepr_change_invoice_desc', 10, 2);

mepr_pdf_invoice_filename

Description

Change the file name when an invoice is downloaded.

Parameters

$file_name Filename of PDF invoice

Example

add_filter('mepr_pdf_invoice_filename', function($file_name) {
  $file_name = 'mepr_txn_invoice.pdf';
  return $file_name;
}, 10, 1);

mepr-hide-cpt-access-column

Description

Remove the Access column in the Custom Post Types pages in the 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 the MemberPress Cancel URL in the Actions column on the Account 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 on the signup 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', 10, 2);

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 the 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 the 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');

mepr_user_pw_reset_title

Description

Change the title of password reset email sent to user

Example

function mepr_user_pw_reset_title() {
  return 10;
}

add_filter('mepr_user_pw_reset_title', 'mepr_user_pw_reset_title');

mepr_admin_pw_reset_title

Description

Change the title of password reset email sent to admin

Example

function mepr_admin_pw_reset_title() {
  return 10;
}

add_filter('mepr_admin_pw_reset_title', 'mepr_admin_pw_reset_title');

mepr-userroles-add-roles

Description

Add the role to a user when a subscription is active

Parameters

$roles_user_should_have Array

$wp_user User Object

Example

function mepr_userroles_add_roles($roles_user_should_have, $wp_user) {
  array_push($roles_user_should_have, 'custom_role');
  return $roles_user_should_have;
}

add_filter('mepr-userroles-remove-roles', 'mepr_userroles_remove_roles', 10, 2);

mepr-userroles-remove-roles

Description

Remove role from a user when the status of subscription changes

Parameters

$roles_to_remove Array

$wp_user User Object

Example

function mepr_userroles_remove_roles($roles_to_remove, $wp_user) {
  // Do what you need
  return $roles_to_remove;
}

add_filter('mepr-userroles-remove-roles', 'mepr_userroles_remove_roles', 10, 2);

mepr_reminder_lookup

Description

Change reminder name and description

Parameters

$lookup Array

$reminder Array of reminders

Example

function mepr_reminder_lookup_fn($lookup, $reminder) {
  $lookup['member-signup']['after']['name'] = $reminder->post_title;
  $lookup['member-signup']['before']['name'] = $reminder->post_title;
  return $lookup;
}

add_filter('mepr_reminder_lookup', 'mepr_reminder_lookup_fn', 10, 2);

mpcs_courses_per_page

Description

Change the number of courses displayed on the Courses page

Example

function mpcs_courses_per_page() {
  return 10;
}

add_filter('mpcs_courses_per_page', 'mpcs_courses_per_page');

mpcs_classroom_style_handles

Description

Allow additional stylesheets to be loaded for courses and lessons when ReadyLaunchâ„¢ is enabled for Courses.

Parameters

$allowed_handles Array of allowed stylesheet handles

Example

add_filter('mpcs_classroom_style_handles', function($allowed_handles){
  $allowed_handles[] = 'YOUR_STYLE_HANDLE_HERE';
  return $allowed_handles;
});

Description

Change the link of the Courses tab on the Account page

Parameters

$link String

Example

function mepr_account_nav_courses_link($link) {
  // Do what you need
  return $link;
}

add_filter('mepr-account-nav-courses-link', 'mepr_account_nav_courses_link');

mepr-account-nav-courses-label

Description

Change the label of the Courses tab on the Account page

Parameters

$label String

Example

function mepr_account_nav_courses_label($label) {
  // Do what you need
  return $label;
}

add_filter('mepr-account-nav-courses-label', 'mepr_account_nav_courses_label');

mepr-account-nav-courses-active-name

Description

Change the active class name of the Courses tab on the Account page

Parameters

$class String

Example

function mepr_account_nav_courses_active_name($class) {
  // Do what you need
  return $class;
}

add_filter('mepr-account-nav-courses-active-name', 'mepr_account_nav_courses_active_name');

mpcs_redirect_lesson_to_sales

Description

Control whether to redirect unauthorized users from the lesson page to the course page

Parameters

$redirect Boolean

$lesson Lesson Object

Example

function mpcs_redirect_lesson_to_sales_fn($redirect, $lesson) {
  // Do what you need
  return $redirect;
}

add_filter('mpcs_redirect_lesson_to_sales', 'mpcs_redirect_lesson_to_sales_fn', 10, 2);

mpcs_redirect_quiz_to_sales

Description

Control whether to redirect unauthorized users from the quiz page to the course page

Parameters

$redirect Boolean

$quiz Quiz Object

Example

function mpcs_redirect_quiz_to_sales_fn($redirect, $quiz) {
  // Do what you need
  return $redirect;
}

add_filter('mpcs_redirect_quiz_to_sales', 'mpcs_redirect_quiz_to_sales_fn', 10, 2);

mpcs_certificate_paper_size

Description

Change certificate paper size from default letter to A4

Parameters

$cert_paper_size String

Example

function mpcs_certificate_paper_size_fn($paper_size) {
  // Do what you need
  return $paper_size;
}

add_filter('mpcs_certificate_paper_size', 'mpcs_certificate_paper_size_fn');

mpcs_classroom_header

Description

Change Classroom header

Parameters

$content String

$classes Array

$back_url String

Example

function mpcs_classroom_header_fn($content, $classes, $back_url) {
  // Do what you need
  return $content;
}

add_filter('mpcs_classroom_header', 'mpcs_classroom_header_fn', 10, 3);

mpcs_classroom_sidebar

Description

Change Classroom sidebar

Parameters

$content String

Example

function mpcs_classroom_sidebar_fn($content) {
  // Do what you need
  return $content;
}

add_filter('mpcs_classroom_sidebar', 'mpcs_classroom_sidebar_fn');

mpcs_classroom_instructor

Description

Change the Classroom Instructor section

Parameters

$course_instructor String

Example

function mpcs_classroom_instructor_fn($course_instructor) {
  // Do what you need
  return $course_instructor;
}

add_filter('mpcs_classroom_instructor', 'mpcs_classroom_instructor_fn');

mpcs_admin_questions_per_page

Description

Change the number of questions per page in search results in the course Admin area

Parameters

$questions_per_page Number

Example

function mpcs_admin_questions_per_page_fn($questions_per_page) {
  // Do what you need
  return $questions_per_page;
}

add_filter('mpcs_admin_questions_per_page', 'mpcs_admin_questions_per_page_fn');

mpcs-admin-capability

Description

Change the default remove_users capability to grant users access to the Courses section in WordPress Dashboard

Parameters

$capability String

Example

function mpcs_admin_capability($capability) {
  // Do what you need
  return $capability;
}

add_filter('mpcs-admin-capability', 'mpcs_admin_capability');

mpcs_attempt_score

Description

Change score message (e.g. Score: 2/4 (50%)) in attempts view.

Parameters

$score String

$attempt Attempt Object

Example

function mpcs_attempt_score_fn($score, $attempt) {
  // Do what you need
  return $score;
}

add_filter('mpcs_attempt_score', 'mpcs_attempt_score_fn', 10, 2);

mpcs_attempt_score_percent

Description

Change the score percent message (e.g. Score: 50%) on the lesson page and in the lessons list

Parameters

$score String

$attempt Attempt Object

Example

function mpcs_attempt_score_percent_fn($score, $attempt) {
  // Do what you need
  return $score;
}

add_filter('mpcs_attempt_score_percent', 'mpcs_attempt_score_percent_fn', 10, 2);

mpcs_get_score_for_answer

Description

Change score value based on the given value

Parameters

$score Number

$answer Answer Object

$question Question Object

Example

function mpcs_get_score_for_answer_fn($score, $answer, $question) {
  // Do what you need
  return $score;
}

add_filter('mpcs_get_score_for_answer', 'mpcs_get_score_for_answer_fn', 10, 3);

mpcs_is_answer_correct

Description

Control whether an answer is correct

Parameters

$is_correct Boolean

$answer Answer Object

$question Question Object

Example

function mpcs_is_answer_correct_fn($is_correct, $answer, $question) {
  // Do what you need
  return $is_correct;
}

add_filter('mpcs_is_answer_correct', 'mpcs_is_answer_correct_fn', 10, 3);

mpcs_display_feedback_incorrect_prefix

Description

Control whether display the question feedback

Parameters

$display_feedback Boolean

$question Question Object

Example

function mpcs_display_feedback_incorrect_prefix_fn($display_feedback, $question) {
  // Do what you need
  return $display_feedback;
}

add_filter('mpcs_display_feedback_incorrect_prefix', 'mpcs_display_feedback_incorrect_prefix_fn', 10, 2);

mpcs_question_feedback_html

Description

Change the question feedback HTML

Parameters

$feedback String

$question Question Object

Example

function mpcs_question_feedback_html_fn($feedback, $question) {
  // Do what you need
  return $feedback;
}

add_filter('mpcs_question_feedback_html', 'mpcs_question_feedback_html_fn', 10, 2);

mpcs_certificate_pdf_file_height

Description

Change the height of the certificate PDF

Parameters

$height String

Example

function mpcs_certificate_pdf_file_height_fn($height) {
  // Do what you need
  return $height;
}

add_filter('mpcs_certificate_pdf_file_height', 'mpcs_certificate_pdf_file_height_fn');

mpcs_question_label

Description

Change question title

Parameters

$label String

$question Question Object

Example

function mpcs_question_label_fn($label, $question) {
  // Do what you need
  return $label;
}

add_filter('mpcs_question_label', 'mpcs_question_label_fn', 10, 2);

mpcs_question_required_indicator

Description

Control whether display the required indicator next to the question title

Parameters

display_required_indicator Boolean

$question Question Object

Example

function mpcs_question_required_indicator_fn(display_required_indicator, $question) {
  // Do what you need
  return display_required_indicator;
}

add_filter('mpcs_question_required_indicator', 'mpcs_question_required_indicator_fn', 10, 2);

mpcs_question_options

Description

Change options displayed in multiple-choice and multiple-answer questions

Parameters

$options Array

$question Question Object

Example

function mpcs_question_options_fn($options, $question) {
  // Do what you need
  return $options;
}

add_filter('mpcs_question_options', 'mpcs_question_options_fn', 10, 2);

mpcs_certificate_pdf_course_title

Description

Change the format of the course title in the PDF certificate

Parameters

$course_title String

Example

//Change the course title format in the PDF certificate from the default (each letter uppercase) to the original course title formating

function mpcs_certificate_pdf_course_title_fn($course_title) {
  return $course_title;
}

add_filter('mpcs_certificate_pdf_course_title', 'mpcs_certificate_pdf_course_title_fn');

mpcs_certificate_pdf_completion_date

Description

Change the format of the Completion date in the PDF certificate

Parameters

$date_format String

Example

//Change the Completion date format in the PDF certificate to the default date format from WordPress settings

function mpcs_certificate_pdf_completion_date_fn($date_format) {
  return get_option( 'date_format' );
}

add_filter('mpcs_certificate_pdf_completion_date', 'mpcs_certificate_pdf_completion_date_fn');

mpcs_certificate_pdf_expiration_date

Description

Change the format of the Expiration date in the PDF certificate

Parameters

$date_format String

Example

//Change the Expiration date format in the PDF certificate to the default date format from the WordPress settings

function mpcs_certificate_pdf_expiration_date_fn($date_format) {
  return get_option( 'date_format' );
}
add_filter('mpcs_certificate_pdf_expiration_date', 'mpcs_certificate_pdf_expiration_date_fn');

Note: If you are using a page builder like Elementor, while the ReadyLaunchâ„¢ template is enabled for Courses, please read our article on How to Edit Lessons in with ReadyLaunchâ„¢ and a Page Builder.

Was this article helpful?

Related Articles

computer girl

Get MemberPress today!

Start getting paid for the content you create.