• Resolved Atdhe Boshnjaku

    (@atdheboshnjaku)


    Hello,

    About a month or 2 ago, we noticed that the renew button no longer appears in the account, even though some users have less than 15 days until their subscription expires or some are even expired, they do not see a renew button, any idea why and how to fix?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Georgian Cocora

    (@raster02)

    Hello @atdheboshnjaku,

    Thank you for your message.

    You seem to be right, there is an issue with the Renew button. This will be fixed in the update to the plugin which will be released sometime next week.

    Regards.

    Thread Starter Atdhe Boshnjaku

    (@atdheboshnjaku)

    Hi @raster02,

    Thanks for acknowledging the issue and getting back to me. I updated to version 2.13.9 however again we dont see the Renew button, only the remove one.

    Any chance you can provide a quick script for a shortcode to get the current active subscription of a client and add the custom link in so that I can display that in until this gets sorted out?

    ?pms-action=renew_subscription&subscription_id=XXX&subscription_plan=XXX&pmstkn=XXXXXX

    This would solve our current issue, thanks.

    Plugin Author Georgian Cocora

    (@raster02)

    Hello @atdheboshnjaku,

    It’s not that simple. If the action isn’t available, that URL will not work either. You can generate those type of URLs using a shortcode that we have: https://www.cozmoslabs.com/docs/paid-member-subscriptions/shortcodes/#Usage

    The change that was added in the latest version only forces the button to show for Expired subscriptions just like we showed it for Canceled all the time. Your issue seems different thought, initially I thought I was able to reproduce it as well but then I realized that it actually works in the parameters that we have setup and only made this slight change.

    We need to look at your specific scenario, maybe there’s a situation where it doesn’t work right. Could you please open a ticket on our website (you can select pre-sale) so we can try to investigate this further? Here’s the URL: : https://www.cozmoslabs.com/support/open-ticket/

    Regards.

    Thread Starter Atdhe Boshnjaku

    (@atdheboshnjaku)

    Hi @raster02

    I tested manually and when I changed the values in for a client where it wasnt working, it showed me the payment page just fine, only thing I dont see in the docs is the pms token, could you tell me the function that generates that please and I will show you what I come up with, I have everything else as I went through the docs, thanks

    Plugin Author Georgian Cocora

    (@raster02)

    Hello @atdheboshnjaku,

    That’s a nonce. Can you try to use this function to generate the Renew link: pms_get_renew_url()? It should give you what you want.

    You can look at the definition to figure out how the nonce is generated.

    Regards.

    Thread Starter Atdhe Boshnjaku

    (@atdheboshnjaku)

    Hi @raster02,

    Sorry I didnt reply earlier, I already figured it out, I am pasting the code I used in case someone else is having the issue and they can use this solution:

    // Forcefully return a renew button by Atdhe Boshnjaku
    add_shortcode('bb_custom_renew_link', 'bb_get_renew_link');
    function bb_get_renew_link() {
    // Get the current user ID
    $user_id = get_current_user_id();

    // Fetch member subscriptions
    $member = pms_get_member($user_id);

    // Check if the member object exists and has subscriptions
    if (!$member || empty($member->subscriptions)) {
    return '<p>No active subscriptions found.</p>';
    }

    // Prepare an empty string for output
    $output = '';

    // Loop over subscriptions
    foreach ($member->subscriptions as $subscription) {
    // Check if the expiration date is within the next 15 days or already expired
    $current_date = new DateTime();
    $expiration_date = new DateTime($subscription['expiration_date']);
    $interval = $expiration_date->diff($current_date);

    // Show button if already expired or expires in 15 days or less
    if ($expiration_date < $current_date || $interval->days <= 15) {
    // Only process active subscriptions
    if ($subscription['status'] === 'active' || $subscription['status'] === 'expired') {
    // Get the subscription plan name
    $subscription_plan = pms_get_subscription_plan($subscription['subscription_plan_id']);
    $plan_name = $subscription_plan ? $subscription_plan->name : 'Membership';

    // Generate the URL for renewing this subscription
    $renew_url = wp_nonce_url(
    add_query_arg(
    array(
    'pms-action' => 'renew_subscription',
    'subscription_id' => $subscription['id'],
    'subscription_plan' => $subscription['subscription_plan_id'],
    ),
    site_url('/account/') // Replace with the actual account page URL if different
    ),
    'pms_member_nonce', // Action name for the nonce
    'pmstkn' // Query parameter for the nonce
    );

    // Append an anchor tag for this subscription
    $output .= sprintf(
    '<div class="bb-renew-button"><p>Please use this Renew Membership button only if you do not see a Renew one by your subscriptions below:</p><a href="%s">Renew %s</a></div>',
    esc_url($renew_url),
    esc_html($plan_name)
    );
    }
    }
    }

    // If no active subscriptions, return a message
    if (empty($output)) {
    return '<p>No active subscriptions available for renewal.</p>';
    }

    // Return the generated anchor tags
    return $output;
    }

    Then to show the button simply use the shorcode block and add this shortcode: [bb_custom_renew_link]

    Plugin Author Georgian Cocora

    (@raster02)

    Hello @atdheboshnjaku,

    It’s good that it works for you.

    Please keep in mind that the issue is with your setup somewhere, people are not supposed/required to use this code to make this feature work. If you wish to investigate this further, please open a ticket as advised.

    Regards.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Renew button not appearing’ is closed to new replies.