• Skip to primary navigation
  • Skip to main content

RocketGeek

Home of WP-Members, The Original WordPress Membership Plugin

  • WordPress Plugins
    • WP-Members
      • FAQs
      • Quick Start
      • Documentation
      • Extensions
    • Advanced Options
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Download Protect
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Invite Codes
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • MailChimp Integration
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • PayPal Subscriptions
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Salesforce Web-to-Lead
    • Security
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Text Editor
      • Purchase the Plugin
      • Get the Pro Bundle
    • User List
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • User Tracking
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Memberships for WooCommerce
    • WordPass
  • Store
    • Cart
    • Checkout
  • Blog
    • Basics [Free]
    • Tips and Tricks
    • Filters
    • Actions
    • Code Snippets
    • Shortcodes
    • Design
    • Release Announcements
  • Contact
  • Sign In
  • Show Search
Hide Search
Home » Tips and Tricks » PayPal Subscription Extension Bulk Extend Users Snippet

PayPal Subscription Extension Bulk Extend Users Snippet

Chad Butler · Jun 15, 2014 ·

This post has been set to “draft” as this feature is now part of the extension and this snippet is no longer needed.

At present, the PayPal Subscription Extension provides for bulk expiring users, but not for bulk application of an expiration extension.

This code snippet will add a bulk extend process to the bottom menu selection.  The bulk action dropdown will include “Extend” and there will be a number of periods selection and then a selection for the time period.

If I have opportunity to improve on this process, it may make its way into the PayPal Subscription Extension.  For now, in order to make use of this functionality, add the following code snippet to your theme’s functions.php file.

This article is only available to WP-Members Support Subscribers. If you have an existing subscription, please login below. If you do not have a current support subscription, you can purchase a support subscription here.

Already a Member? Log In Here
   
Forgot password? Click here to reset

To gain full access to WP-Members premium content, a current support subscription is required. You can purchase an annual support subscription for as little as $59, which provides you with access to priority support, a customer support forum, access to code snippets, and more.

Why wait? Choose your subscription option here.

[
Why join?]

Tips and Tricks paypal

Welcome to RocketGeek Interactive › Forums › PayPal Subscription Extension Bulk Extend Users Snippet

Tagged: PayPal

  • This topic has 7 replies, 3 voices, and was last updated 6 years, 4 months ago by Chad Butler.
Viewing 3 reply threads
  • Author
    Posts
    • June 15, 2014 at 8:57 am #5134
      Chad Butler
      Keymaster

      At present, the PayPal Subscription Extension provides for bulk expiring users, but not for bulk application of an expiration extension. This code sni
      [See the full post at: PayPal Subscription Extension Bulk Extend Users Snippet]

    • June 15, 2014 at 8:12 pm #5140
      hnps
      Participant

      Hi Chad,

      Thanks!!!! I hope this feature proves useful to others as well.

      I’ve been trying to add the snippet to my functions.php. I tried both adding it to the child theme I’ve created for 2012, and also to the 2012 theme file itself. Editing the functions.php of 2012 did not create the additional pulldown required, and editing the same file on my child theme generated a blank website result. (So for now I’ve rolled everything back to the original versions.)

      I’m not very conversant in php, but I’ve been told child themes are the way to go. I’ve got them working for css (which I’m more familiar with) but not for functions.php. Here is the total contents for the child theme functions php I created that didn’t work. Can you see if there’s something in the beginning or end that’s out of whack?

      		
      		wp_redirect( $sendback );
      		exit();
      	}
      ?> //Closing PHP tag
      • June 15, 2014 at 9:45 pm #5143
        Chad Butler
        Keymaster

        You’re correct on using a child theme. This is the best approach to keeping your customizations outside the theme in case you need to load an update to the main theme.

        I redacted the code down to just the part that was a problem for you. There are actually two problems – one that would break the site, and the other relatively minor.

        (1) you are actually missing the very last part of the code snippet which is the closing curly brace for the function } That’s the part that is breaking things for you because omitting that throws off everything that comes after it.

        (2) your comment //closing PHP tag is a PHP comment outside of where you have closed PHP. This won’t break your site, but it will not be skipped as a comment. It will probably be displayed as HTML. If you want a comment there, it needs to be inside the ?>

        (2b) you don’t need a closing ?> delimiter at the end of your functions.php. It’s good idea to just omit it altogether.

        So to recap – remove the ?> at the end and the comment, and place a closing curly brace for the function at the end } and you should be fine.

    • June 16, 2014 at 1:52 pm #5153
      hnps
      Participant

      Fantastic! It’s working now. The only issue I see is that the EXTEND option appears in the bulk pulldown at the BOTTOM of the page but not the one at the TOP. You had mentioned to use the bottom pulldown but I didn’t notice that part.

      I think this issue is resolved!! And I’m sure this feature will be useful to us going forward and hopefully others as well.

      Best,
      Kevin

      • June 16, 2014 at 4:32 pm #5158
        Chad Butler
        Keymaster

        That’s good to hear you got it working. I expect to be working this into the extension as an actual feature.

        Sorry about the confusion with the bottom vs. top part. Because of the additional dropdowns involved, this needed to go at the bottom to avoid layout issues.

    • September 5, 2014 at 12:46 pm #5806
      dtmnash
      Participant

      is expires still the meta value for this in version .4?

      below is my code and i’m not seeing it get reflected properly in the database or the admin panels for the users

      if i read the expires value from get_user_meta it appears to have updated correctly.

      $users = get_users(array('exclude' => array(1)));
      
      $timezone = new DateTimeZone('UTC');
      $format = 'm/d/Y';
      $currentDate = date($format);
      $today = date_create_from_format($format, date($format), $timezone);
      $interval = date_interval_create_from_date_string('1 days');
      
      $date = date_sub($today, $interval);
      $expireValue = $date->format($format);
      
      foreach($users as $user){
      
       update_user_meta( $user, 'expires', $expireValue );
       update_user_meta( $user, 'exp_type', 'subscription' );
      
       $newExpires = get_user_meta($user, 'expires', true);
      }
      • September 5, 2014 at 1:24 pm #5809
        dtmnash
        Participant

        I figured this out, i was confusing your users array with the return of get_users.

        update_user_meta takes the id so in my snippet above changing

        foreach($users as $user){
        
         update_user_meta( $user, 'expires', $expireValue );
         update_user_meta( $user, 'exp_type', 'subscription' );
        
         $newExpires = get_user_meta($user, 'expires', true);
        }

        to

        foreach($users as $user){
        
         update_user_meta( $user->ID, 'expires', $expireValue );
         update_user_meta( $user->ID, 'exp_type', 'subscription' );
        
         $newExpires = get_user_meta($user, 'expires', true);
        }

        did the trick

        • September 5, 2014 at 2:32 pm #5810
          Chad Butler
          Keymaster

          Yep – that would do it! 😉

  • Author
    Posts
Viewing 3 reply threads
  • You must be logged in to reply to this topic.
Log In

Ready to get started?

Join Today!

© 2021 · butlerblog.com · RocketGeek is built using WordPress, WP-Members, and the Genesis Framework

  • butlerblog.com
  • WP-Members Support Subscription
  • Terms of Service
  • Refund Policy