1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

New Cron Entry... Super lost.

Discussion in 'XenForo Questions and Support' started by Jake Hakoda Shirley, May 8, 2011.

  1. Jake Hakoda Shirley

    Jake Hakoda Shirley Active Member

    Hey guys, I was looking at the Trophy Check cron job, and I wanted to write one that would make a user that has been registered over 3 days get put into a certain group. Any help with this?

    This is what I fiddled out. I have no way to debug this other than trial and error.
    PHP:
    <?php

    /**
    * Cron entry for trial checking
    *
    * @package XenForo_Trial
    */
    class XenForo_CronEntry_Trial
    {
        
    /**
        * Runs the cron-based check for trial termination
        */
        
    public static function runTrialCheck()
        {
            
    /* @var $userModel XenForo_Model_User */
            
    $userModel XenForo_Model::create('XenForo_Model_User');

    // Assuming that 13 is the group number for your trial members
    // Assuming that 'timeinseconds' is a real number

            
    $users $userModel->getUsers(array(
                
    'secondary_goup_ids' => 13,
                
    'register_date' => array('>'XenForo_Application::$time timeinseconds)
            ));

            foreach (
    $users AS $user)
            {
    // Not too sure on how to set fields...
                
    $user['secondary_group_ids'] = null;
            }
        }
    }
     
  2. ragtek

    ragtek Guest

    Code:
    foreach ($users AS $user){
    $dw = XenForo_DataWriter::create('XenForo_DataWriter_User');
    $dw->setExisting($user);
    $dw->setSecondaryGroups($foo);
    $dw->save();
    }
     
  3. Jake Hakoda Shirley

    Jake Hakoda Shirley Active Member

    Mind writing in a small selection parameter in regards to join date v. current?

    Also, <3.
     

Share This Page