Can it be solved that only the wall entries will be deleted automatically by the admin after 2 weeks?
Thank you very much, now it's so good, I'll fix the cron setup.
OF COURSE?!?
Arsalan did not advise you to do anything like that!
You wanted to delete entries older than 14 days, hence it is sufficient to run this query once a day,
and not constantly when your site is being accessed.
This code has to be a separate file executed by CRON.
In doubt ask your provider which way to set up a daily cron job.
Of course I put it in the index.php file.
2 months ago Arsalan wrote:
Yes it requires to have a cron job to be written
You did not put that code into index.php of Ossn?!?
Thank you so much for everything, I learned a lot. I wrote the change in the index.php file, testing it constantly.
As a final exercise you may add the 'older than 14 days' condition to your query like
SELECT * FROM `ossn_object` WHERE subtype = 'wall' AND type = 'user' AND FROM_UNIXTIME(time_created) <= DATE_SUB(NOW(), INTERVAL 2 WEEK)
This time you should get 0 rows as a result, because all existing rows are not old enough to match the condition.
Ok, now that we know what has to happen on the SQL low level, we only have to 'translate' that missing type = 'user'
condition to your PHP code
$listUser = $wall->GetPosts(array(
'type' => 'user',
'page_limit' => false,
'wheres' => array(
"(FROM_UNIXTIME(o.time_created) <= DATE_SUB(NOW(), INTERVAL 2 WEEK))"
)));
That's it.
Super :)
Almost perfect! ;)
All found rows are of subtype wall
now
but your request was to leave the posts in Groups untouched, right?
That's why we still have to refine the query a bit to find only rows of type user
So, click Show query box to return to your former window
and change the query like
SELECT * FROM `ossn_object` WHERE subtype = 'wall' AND type = 'user'
execute this new query and verify the result:
there should be no more rows of type group
Correct!
The query means:
SELECT all columns FROM the table ossn_object
WHERE everything is valid - no restriction
That's why we're getting the complete number of rows.
Now remember what's inside the GetPosts
function
$default = array(
'subtype' => 'wall',
'order_by' => 'o.guid DESC'
);
And that means: We want only rows of subtype wall
(the ordering is of no interest here, because in the end we would delete the rows anyway)
Okay, so back in phpmyadmin, let's change the query according to the GetPosts
function
to look like
SELECT * FROM `ossn_object` WHERE subtype = 'wall'
Then click the GO button to execute the query
and make a screenshot of the result
Due to the many requests in the past for additonal features and components we have decided to develope a premium version. Features like Hashtags, Videos, Polls, Events, Stories, Link Preview, etc included in it.
$199 (Life Time)