Restrict Content Pro

Updated

In order to make the ‘User Lost Password – For User’ notification within BNFW work correctly with Restrict Content Pro, you’ll need to add the following code to your functions.php file in your theme.
You’ll then need to use [cci lang=”php”]%passwordresetlink%[/cci] instead of the default BNFW [cci lang=”php”][password_reset_link][/cci] shortcode in the notification.

[cc lang=”php”]

// Registering Your Email Tag
function bnfw_rcp_email_template_tags( $email_tags ) {
$email_tags[] = array(
‘tag’ => ‘passwordresetlink’,
‘description’ => __( ‘Description of my custom tag.’ ),
‘function’ => ‘bnfw_rcp_my_custom_tag_callback_function’
);

return $email_tags;
}
add_filter( ‘rcp_email_template_tags’, ‘bnfw_rcp_email_template_tags’ );

// Creating Your Callback Function
function bnfw_rcp_my_custom_tag_callback_function( $user_id = 0, $payment_id = 0 ) {

// Return RCP Password Reset Link
return esc_url_raw( bnfw_retrieve_password_message( $message, $key, $user_login, $user_data ) );
}

// Re-create RCP Password Reset Link
function bnfw_retrieve_password_message( $message, $key, $user_login, $user_data ) {
$user_data = get_user_by( ’email’, trim( $_POST[‘rcp_user_login’] ) );
$user_login = $user_data->user_login;
$key = get_password_reset_key( $user_data );

$message = esc_url_raw( add_query_arg( array(
‘rcp_action’ => ‘lostpassword_reset’,
‘key’ => $key,
‘login’ => rawurlencode( $user_login )
),
$_POST[‘rcp_redirect’] ) ) . “\r\n”;

return $message;
}
add_filter( ‘retrieve_password_message’, ‘bnfw_retrieve_password_message’, 10, 4 );

[/cc]