Support » Plugins » After x days of membership do function? Any ideas

  • Tried searching for this and havnt really found anything that would help including the cron stuff.

    Basically, I’m looking to update a user in the database manually (not through any plugins and more of a hack) every month they are a member. So John Doe signs up on February 19th and on the 19th of every month then on we update the database… Any ideas?

    Thanks all

Viewing 3 replies - 1 through 3 (of 3 total)
  • You might be able to write a PHP script that did something like:

    * get today’s date, subtract one month from it, store it in a variable.

    * use get_users, with a meta tag of user_registered and the variable from the previous step to get the desired array of users.

    * loop the array, doing whatever you are going to do to the user metadata (this wasn’t exactly explained, so I’m keeping it vague)

    * loop the array again, writing the modified metadata back into the user table with the wp_update_user function

    The specifics in the last two bullet items will depend upon what you’re trying to accomplish, naturally.

    Thanks Andrew.. got it withthe help of this too

    I basically want to allow the users access to 20 more posts every month..

    //$posts_total = ($months + 1) * 20;
    $date2 = date('l jS F Y'); 
    	// get all the users who are registered
        $allusersquery = "SELECT * FROM wp_users";
        $usersresults = mysql_query($allusersquery);
        while($myuser = mysql_fetch_assoc($usersresults)) {
        		$date1 = $myuser['user_registered'];
        		echo "<br>";
    $diff = abs(strtotime($date2) - strtotime($date1));
    $months = floor(($diff - 0 * 365*60*60*24) / (30*60*60*24));
    printf("<br>%d months", $months);
    $posts_total = ($months + 1) * 20;
    echo "&nbsp;".$posts_total." Posts";

    >> allow the users access to 20 more posts every month . . .

    Not sure I quite understand. You’re putting a quota on the number of posts that a user can create and publish every month? Or you’re allowing them to read/consume premium content at a rate of 20 articles per month?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘After x days of membership do function? Any ideas’ is closed to new replies.