We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 42042
    • 140 Posts
    Hi All,

    I'm working on a challenging project involving members and video's. The basic idea is that there are free video's and paid videos. For the paid video you need to have a "membership" to view. My question to you guys is: what's the best way to validate the membership and show the video and store membership expiration date?

    The challenges

    1. Members can signup and login
    2. Members can make a payment
    3. Members can view paid videos

    The idea

    1. Login extra for handling all the member stuff
    2. I'd have to work with iDeal(Dutch) so I thought of Mollie API?
    3. Once the payment is successful I store the expiration date of the membership in an extended field on the member. For the video I use a snippet which checks if the user has a valid membership or not.

    I'm a enthusiastic developer willing to learn a lot so please don't be shy! Thanks in advance for your help community.

    Best,
    Ilja

    This question has been answered by BobRay. See the first response.

      • 17301
      • 932 Posts
      I believe there's an extra available called SubscribeMe that has the paid membership facility within it.
        ■ email: [email protected] | ■ website: https://alienbuild.uk

        The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
        • 42042
        • 140 Posts
        Hi LK,

        Thanks for the fast reply. The extra is great, thing is: it has only a PayPall gateway. I need to work with iDeal.
        • discuss.answer
          • 3749
          • 24,544 Posts
          You might consider using the User Profile's DOB (date of birth) field for the expiration date if you're not already using it. It would be faster and easier than an extended field.

          Even faster, would be to use the remote_key field of the modUser object. It's a string field, so you could store either a human-readable date or a unix timestamp there. Since $modx->user is always available for logged-in users, this would get it in your snippet:

          $expDate = $modx->user->get('remote_key');
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 42042
            • 140 Posts
            Quote from: BobRay at Nov 20, 2016, 05:44 AM
            You might consider using the User Profile's DOB (date of birth) field for the expiration date if you're not already using it. It would be faster and easier than an extended field.

            Even faster, would be to use the remote_key field of the modUser object. It's a string field, so you could store either a human-readable date or a unix timestamp there. Since $modx->user is always available for logged-in users, this would get it in your snippet:

            $expDate = $modx->user->get('remote_key');

            Thanks for your response Bob! These are both better options than the extended field! How do you think of the idea storing the date on successful payment and show the video in a snippet something like:

            
            if (!$modx->user->isAuthenticated('web')) {
            $startdate = "16-May-2016";
            $expire = strtotime($startdate. ' + 2 days');
            $today = strtotime("today midnight");
            
             if($today >= $expire){
              // Show message: Membership not valid
             }else {
              // Show video
            }
            }else {
             // Show messge: login
            }
            
              • 3749
              • 24,544 Posts
              It looks good to me, though you might want to add another section for when it's close to running out, warning the user that their subscription will lapse in x days and suggesting that they "click here" to re-up.
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 42042
                • 140 Posts
                Quote from: BobRay at Nov 21, 2016, 08:17 PM
                It looks good to me, though you might want to add another section for when it's close to running out, warning the user that their subscription will lapse in x days and suggesting that they "click here" to re-up.

                Good point. Thanks for your suggestion. I will play with this and will respond back in this thread.
                  • 42042
                  • 140 Posts
                  Quote from: BobRay at Nov 20, 2016, 05:44 AM
                  You might consider using the User Profile's DOB (date of birth) field for the expiration date if you're not already using it. It would be faster and easier than an extended field.

                  Even faster, would be to use the remote_key field of the modUser object. It's a string field, so you could store either a human-readable date or a unix timestamp there. Since $modx->user is always available for logged-in users, this would get it in your snippet:

                  $expDate = $modx->user->get('remote_key');

                  @BobRay I've managed to get it all working. Thing is, I can't get the remote key to set proper. I'd go for the DOB instead. How do you set the remote key?

                  This won't work:
                  $expDate = $modx->user->set('remote_key', '10-10-2016');
                  
                    • 3749
                    • 24,544 Posts
                    Are you saving the user object after setting that?

                    $modx->user->save();


                    If it's not that, sometimes you have to retrieve the user object before making changes to it.

                    $usr = $modx->getObject('modUser', $modx->user->get('id'));
                    $usr->set('remote_key', '10-10-2016');
                    $usr->save();
                      Did I help you? Buy me a beer
                      Get my Book: MODX:The Official Guide
                      MODX info for everyone: http://bobsguides.com/modx.html
                      My MODX Extras
                      Bob's Guides is now hosted at A2 MODX Hosting