Email Filters

Note: This is part of the developer docs and is considered custom code.
Unfortunately, we cannot provide support for custom code at this time as we do not have the additional resources that would be necessary to provide support for custom code.

If you need assistance with this, please reach out to our list of consultants for further assistance:
https://codeable.io/developers/restrict-content-pro/

All email messages and subjects have their own filters. You can use these to change the message contents for each membership level or based on any other user/membership details. This is also useful if you want to send emails in multiple languages.

Here's a full list:

Paid Membership Activation Email:

$message = apply_filters( 'rcp_subscription_active_email', $message, $user_id, $status, $membership );
$subject = apply_filters( 'rcp_subscription_active_subject', $subject, $user_id, $status, $membership );

Free Membership Activation Email:

$message = apply_filters( 'rcp_subscription_free_email', $message, $user_id, $status, $membership );
$subject = apply_filters( 'rcp_subscription_free_subject', $subject, $user_id, $status, $membership );

Trial Membership Activation Email:

$message = apply_filters( 'rcp_subscription_trial_email', $message, $user_id, $status, $membership );
$subject = apply_filters( 'rcp_subscription_trial_subject', $subject, $user_id, $status, $membership );

Canceled Membership Email:

$message = apply_filters( 'rcp_subscription_cancelled_email', $message, $user_id, $status, $membership );
$subject = apply_filters( 'rcp_subscription_cancelled_subject', $subject, $user_id, $status, $membership );

Expired Membership Email:

$message = apply_filters( 'rcp_subscription_expired_email', $message, $user_id, $status, $membership );
$subject = apply_filters( 'rcp_subscription_expired_subject', $subject, $user_id, $status, $membership );

Payment Received Email:

$message = apply_filters( 'rcp_payment_received_email', $message, $payment_id, $payment );

In this email, the user ID can be obtained with $payment['user_id']

Renewal Payment Failure Email:

$message = apply_filters( 'rcp_subscription_renewal_payment_failed_email', $message, $user_id, $status );
$subject = apply_filters( 'rcp_subscription_renewal_payment_failed_subject', $subject, $user_id, $status );

Manual Payment (Admin Notification)

$admin_message = apply_filters( 'rcp_before_admin_email_manual_payment_thanks', $admin_message, $member->ID );

Example Usage

This example changes the contents of the "Active Membership Email" if the user is on membership level #3.

function ag_new_subscription_active_email( $message, $user_id, $status, $membership ) {
    $level_id = $membership->get_object_id();

    // Change the email contents if they're on level #3.
    if( 3 == $level_id ) {
        $message = __( 'Your new message can go in here.', 'rcp' );
    }

    return $message;
}

add_filter( 'rcp_subscription_active_email', 'ag_new_subscription_active_email', 10, 4 );

This example changes the contents of the Manual Payment admin notification email:

function ag_rcp_admin_email_manual_payment( $message, $user_id ) {
    $member = new RCP_Member( $user_id );
    $membership_level = $member->get_pending_subscription_name();

    // Customize this however you like.
    $new_message = __( 'Hello', 'rcp' ) . "\n\n" . $member->display_name . ' (' . $member->user_login . ') ' . __( 'just submitted a manual payment on', 'rcp' ) . ' ' . $site_name . ".\n\n" . __( 'Membership level', 'rcp' ) . ': ' . $membership_level . "\n\n";

    return $new_message;
}
add_filter( 'rcp_before_admin_email_manual_payment_thanks', 'ag_rcp_admin_email_manual_payment', 10, 2 );
Powered by Zendesk