This shortcode can be used to display information about the current/any users subscription.
Parameters:
Usage:
[pms-subscription-info key="plan_name"]
add_shortcode( 'pms-subscription-info', 'pmsc_subscription_info_shortcode' );
function pmsc_subscription_info_shortcode( $atts ){
$atts = shortcode_atts( array(
'id' => get_current_user_id(),
'subscription_plan' => '',
'key' => '',
), $atts );
if (empty($atts['key']) || empty($atts['id']))
return;
$args = array( 'user_id' => $atts['id'] );
if( !empty( $atts['subscription_plan'] ) )
$args['subscription_plan_id'] = $atts['subscription_plan'];
$member = pms_get_member_subscriptions( $args );
if ( empty( $member ) )
return '';
$subscription_plan = pms_get_subscription_plan( $member[0]->subscription_plan_id );
$subscription_statuses = pms_get_member_subscription_statuses();
switch ($atts['key']) {
case 'start_date':
return ucfirst( apply_filters( 'pms_match_date_format_to_wp_settings', strtotime( get_date_from_gmt( $member[0]->start_date ) ), false ) );
break;
case 'expiration_date':
return ucfirst( apply_filters( 'pms_match_date_format_to_wp_settings', strtotime( get_date_from_gmt( $member[0]->expiration_date ) ), false ) );
break;
case 'next_payment':
return ucfirst( apply_filters( 'pms_match_date_format_to_wp_settings', strtotime( get_date_from_gmt( $member[0]->billing_next_payment ) ), false ) );
break;
case 'status':
return $subscription_statuses[$member[0]->status];
break;
case 'plan_name':
return $subscription_plan->name;
break;
case 'plan_price':
return $subscription_plan->price;
break;
case 'plan_duration':
return $subscription_plan->duration . ' ' . $subscription_plan->duration_unit;
break;
case 'default':
return;
break;
}
}
Accept (recurring) payments, create subscription plans and restrict content on your website. Easily setup a WordPress membership site using Paid Member Subscriptions.
Get Paid Member SubscriptionsCombine the power of Profile Builder with Paid Member Subscriptions to set up user registration, memberships, and recurring revenue.
Get 25% off with the bundle