Trial period registration

Hello to all,

We are starting up a new project, and unfortunately we are also a bit newbies in this framework, so sorry if we are asking something obious but:

What is the best practice/way to make a trial-out register system/process? I mean, let an user register freely but after 30 days, suspend his account until he pays/activate or something.

Do we have to deal with cron processes? or maybe there is a better plugin/built-in framework way? Is there any code/example/snippet about this?

Many thanks in advance,



well, for that particular task I don’t think you would need cron jobs. You just need to know when the user registered and if that date was more than 30 days ago (and they have not payed yet), you just won’t let them log in.

Or better yet, when they register, you’d also have another column in your DB called expire which would hold the expiration date and you can verify against that. (and actually use this column in the future)

there are some registration extensions out there (that you might need do extend!) but they will be a good starting point. ie:


Imehesz I think that is maybe a bit risky solution, because what happens if the server clock breaks or malfuncion for any reason? several hundreds users will have premium account again (at least temporaly), isn’t it?

Another question more in relation to jobs, is how to send an email to the user saying it’s about to close his account several times before do it (1 week, 4 days ago, 2 days ago…).

Searching for schechulding jobs or taks documentation in Yii, I think clearly there is a lack of…

And apart for console commands, that is a very important topic for many people to include in the main definitive guide (maybe we are loosing something)

thanks in advance,


Even if you set a cron job this remains a problem… @Imehesz idea is OK… I would suggest to add one more filed/attribute like "active" so the first time that the program tests the registered date is 30 days old it sets this field to FALSE so that even if the server clock fails this field remains FALSE…

You should be able to rely on some basic things - server clock is one of them. If you don’t want to use a cron job, the described solution is valid IMO.

For this you need a cron job anyway. See below.

By the nature of the web, web applications only run when there’s a request. So any scheduled tasks should better be performed from a cron job (or the task scheduler provided by your OS). There’s a complete page dedicated to this topic in the guide:


Ok, thanks to all for your quick responses!!

We will try to investigate a bit more.

Mike, I saw that page before, but maybe it lacks a cron job example or something…



What example are you missing? If you create a yiic command for a maintenance tasks, simply call it from cron like:

/some/path/to/your/app/protected/yiic yourcommand

Thank you very much, I think its just what we needed.

I got the next exception, when I tried to search in the database through a model : exception ‘CDbException’ with message 'CDbConnection.connectionString cannot be empty.

In a console application can I use the defined models?

Sure. Seems like you’ve missed to configure the db connection for your console application. Check config/console.php.

Yes, was it. Thanks.

I just added and that works :


                        'connectionString' => 'mysql:host=localhost;dbname=******',

                        'emulatePrepare' => true,

                        'username' => '*****',

                        'password' => '*****',

                        'charset' => 'utf8',



Sorry to resurrect this thread, but my question is related.

What are the methods for preventing a user from signing up a trial account over and over?