WordPress.org

Ready to get started?Download WordPress

Forums

After x days of membership do function? Any ideas (4 posts)

  1. peiledoir
    Member
    Posted 1 year ago #

    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

  2. andrewmills
    Member
    Posted 1 year ago #

    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.

  3. peiledoir
    Member
    Posted 1 year ago #

    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";
    }
  4. andrewmills
    Member
    Posted 1 year ago #

    >> 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?

Topic Closed

This topic has been closed to new replies.

About this Topic