Creating a new promotion restriction?

Jaxel

Well-known member
I'm trying to create a promotion on my forums:
  • Add to usergroup "Premium".
  • User is logged in.
  • User has been registered for less than 30 days.
What this would do, is when someone registers, they get a free 30 day trial of our premium membership.

However, "User has been registered for less than X days" does not exist. How would I set this up?
 
So I've done all this and I am running into an issue...

I have my listener:
Code:
<?php

class EWRcanal_Listener_Criteria
{
    public static function user($rule, array $data, array $user, &$returnValue)
    {
        switch ($rule)
        {
            case 'registered_less':
                if (isset($user['register_date']))
                {
                    $daysRegistered = floor((XenForo_Application::$time - $user['register_date']) / 86400);
                    if ($daysRegistered < $data['days'])
                    {
                        $returnValue = true;
                    }
                }
            break;
        }
    }
}
And then I have my template modification:
Code:
<li><label>
    <input type="checkbox" name="user_criteria[registered_less][rule]" value="registered_less" class="Disabler" id="ucrit_registered_less" {xen:checked $userCriteria.registered_less} />
    {xen:phrase ewrcanal_user_has_been_registered_for_less_than_x_days}:</label>
    <div class="criteriaQualifier" id="ucrit_registered_less_Disabler">
        <xen:spinbox name="user_criteria[registered_less][data][days]" value="{$userCriteria.registered_less.days}" size="5" min="0" step="7" />
    </div>
</li>

It looks like its working well... however, when I run the cron-job for Usergroup Promotions; it doesn't want to promote anybody.

So at the top of my listener, I added:
Code:
echo $user['user_id']."<br />";
Theoretically, this should line-by-line, list every user ID on my forums, as it checks each and every user for promotion. However, it's only listing "1"; which is me. It's not checking any other user.
 
You may be wanting to create this promotion criteria yourself, but if not then User Criteria by Waindigo has "user having been registered for less than a certain number of days" amongst others.

**EDIT** Yes, you are wanting to do it yourself.
 
Okay... I figured it out...

The usergroup promotions cronjob only searches for users who have been active in the past hour. I disabled that restriction and ran it; and it ran fine.

Thanks guys.

Also, I have no interest in using other people's addons; when I can do it myself.
 
Back
Top Bottom