Restrict Content Pro
Modify subscription tab output
Coming soon: Restrict Content Pro is becoming Kadence Memberships. You may see both names used while we update the product, documentation, and customer experience.
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/
This snippet demonstrates how you can change what appears on the subscription tab created by Restrict Content Pro – Ultimate Member.
/**
* Remove the default RCP Ultimate Member subscription tab output.
*/
add_action( 'wp_loaded', function () {
if ( ! class_exists( 'RCP_UMUltimateMember2' ) ) {
return;
}
remove_action(
'um_account_content_hook_subscription',
array( RCP_UMUltimateMember2::get_instance(), 'account_page' )
);
} );
/**
* Recreate the subscription tab with modified output.
*
* Ultimate Member runs this hook as a filter. Return the HTML string.
* Requires an active membership record for the profile user.
*/
add_filter( 'um_account_content_hook_subscription', function ( $output, $shortcode_args = array() ) {
$user_id = function_exists( 'um_profile_id' ) ? um_profile_id() : get_current_user_id();
if ( ! $user_id || ! function_exists( 'rcp_get_customer_by_user_id' ) ) {
return $output;
}
$customer = rcp_get_customer_by_user_id( $user_id );
$membership = $customer ? $customer->get_pending_membership() : false;
if ( ! $membership ) {
$memberships = $customer ? $customer->get_memberships() : array();
$membership = ! empty( $memberships ) ? reset( $memberships ) : false;
}
$level_name = $membership ? $membership->get_membership_level_name() : __( 'None', 'rcp' );
$status = $membership ? $membership->get_status() : '';
$expiration = $membership ? $membership->get_expiration_date() : '';
ob_start();
?>
<div class="um-field um-field-subscription">
<div class="um-field-label">
<label><?php esc_html_e( 'Membership', 'rcp' ); ?></label>
</div>
<div class="um-field-area">
<?php echo esc_html( $level_name ); ?>
</div>
</div>
<div class="um-field um-field-subscription-status">
<div class="um-field-label">
<label><?php esc_html_e( 'Status', 'rcp' ); ?></label>
</div>
<div class="um-field-area">
<?php echo esc_html( $status ); ?>
</div>
</div>
<div class="um-field um-field-subscription-expiration">
<div class="um-field-label">
<label><?php esc_html_e( 'Expiration', 'rcp' ); ?></label>
</div>
<div class="um-field-area">
<?php echo esc_html( $expiration ); ?>
</div>
</div>
<?php
return $output . ob_get_clean();
}, 10, 2 );
Filed under
Developer Docs – Tutorials
Was this page helpful?
Thanks for the feedback!