Forum Replies Created

Viewing 7 replies - 1 through 7 (of 7 total)
  • 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]

    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

    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.

    Thread Starter Atdhe Boshnjaku

    (@atdheboshnjaku)

    Hi again,

    Apart from individual cells, If you have a unique class to target all past events that should also work or do you mean that you dont have that either, just asking to confirm, thanks.

    Thread Starter Atdhe Boshnjaku

    (@atdheboshnjaku)

    @raster02 Thank you, this works like a charm. You saved me from having to use a plugin to achieve this ??

    Thread Starter Atdhe Boshnjaku

    (@atdheboshnjaku)

    Hello @raster02,

    So I am trying your suggestion to the best of my knowledge and this is what I am placing in the functions.php of my child theme:

    add_action( 'template_redirect', 'redirect_non_permitted_users' );
    
    function redirect_non_permitted_users () {
        
    	if ( is_singular( 'private-page' ) || is_post_type_archive( 'private-page' ) ) {
    		
            $userID = get_current_user_id();
    		global $post;
    		$authorID = absint($post->post_author);
    
    		if( $userID !== $authorID && ! is_user_logged_in() ){
    			wp_redirect('https://website.com/dashboard/');
    			exit;
    		}
                
        }
    	
    }

    But it has no effect, any chance that I am missing something, thank you for your help.

    • This reply was modified 3 years ago by Atdhe Boshnjaku. Reason: didnt make the code part an actual code

    Hi there,

    I am still having this issue where if I try to checkout with credit card nothing happens, so you fill in the form and no matter how many times you click on the submit button nothing happens, when I click on the “X” I see the error message: “Error! Something went wrong when verifying the payment”.

    I have just recreated my api keys and added them and they were added successfully.

    Wordpress version: 5.8.1
    Forminator: 1.15.2

    link to the form: https://roadtocanada.ca/en/pay-for-service/

    Please assist

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