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