ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Expire membership?

March 12, 2011 9:28am

Subscribe [2]
  • #1 / Mar 12, 2011 9:28am

    leeaston

    634 posts

    Anyone have, know of or fancy writing (I’ll pay) and add-on to expire membership (EE2) from members to guests after a set time period?

    Cheers
    Lee

  • #2 / Mar 12, 2011 11:43am

    Mark Bowen

    12637 posts

    Could you not perhaps just run a cron job which hits a ‘secret’ template on your site which runs a SQL query to do this for you?

    Best wishes,

    Mark

  • #3 / Mar 12, 2011 11:49am

    leeaston

    634 posts

    Hi Mark, nice to see you back on the forums/twitter a bit more.

    Thanks for the idea, I like it - nice and simple. But first I’ll need to figure out how to write an SQL query - first time for everything, so I’m going to give it a go.

    Best wishes
    Lee

  • #4 / Mar 12, 2011 11:50am

    Mark Bowen

    12637 posts

    Hi Lee,

    Thanks for the kind words. It’s nice to be back too 😊

    If you need a hand with the query then just ask back as I’ll be able to let you have that if you need it.

    Best wishes,

    Mark

  • #5 / Mar 12, 2011 12:06pm

    leeaston

    634 posts

    What a bloke, I much prefer to learn by example. Be happy to PayPal you over a few beers for the trouble…

  • #6 / Mar 12, 2011 12:39pm

    Mark Bowen

    12637 posts

    Hiya,

    Here you go :

    <?php
    
        $this->EE =& get_instance();
        $this->EE->db->query("
                        UPDATE exp_members
                        SET group_id = '3'
                        WHERE group_id = '5'
                        AND DATE_ADD(FROM_UNIXTIME(join_date), INTERVAL 1 MONTH) <NOW()
                        ");
    
    ?>

    You’ll need to allow PHP on the template where you place this code and you’ll need to change the 3 to whatever the number of your guest group is and the 5 to whatever the number of the group you are moving them from is.

    You can then just hit the template whenever you like with a cron job and it should just update their member group 30 days after their join_date.

    Hope that helps a bit.

    Best wishes,

    Mark

  • #7 / Mar 13, 2011 8:38am

    Mark Bowen

    12637 posts

    Hi Lee,

    Just wanted to check to see if the query above worked? If not then let me know exactly what you have and I can write a query for you.

    Best wishes,

    Mark

  • #8 / Mar 13, 2011 9:31am

    leeaston

    634 posts

    Hi Mark, I’ve been trying to add to it, rather unsuccessfully so far. What you wrote for me worked spot on, but then I realsised that I only need to apply the membership downgrade to members since30/11/2010 (unix time stamp 1291075200).

  • #9 / Mar 13, 2011 11:03am

    Mark Bowen

    12637 posts

    Hiya,

    Pretty sure this should do it but definitely test lots before using it fully :

    <?php
    
        $this->EE =& get_instance();
        $this->EE->db->query("
                         UPDATE exp_members
                         SET group_id = '3'
                         WHERE group_id = '5'
                         AND DATE_ADD(FROM_UNIXTIME(join_date), INTERVAL 1 MONTH) <NOW()
                         AND join_date >= '1291075200'
                        ");
    
    ?>

    Let me know how that goes.

    Best wishes,

    Mark

  • #10 / Mar 13, 2011 11:12am

    leeaston

    634 posts

    Thanks Mark, what’s your PayPal email address?

  • #11 / Mar 13, 2011 11:26am

    Mark Bowen

    12637 posts

    Well there’s a link in my signature but you really don’t have to do that.

    It’s nice that we can all help each other out on here whenever we can.

    Hopefully the query works correctly for what you need though.

    Best wishes,

    Mark

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases