Advertisement:

Author Topic: Is it possible to disable ads becoming "blocked" after "expiry"?  (Read 839 times)

aguy

  • Newbie
  • *
  • Posts: 8
Hi,
When the ads become "blocked" in the "Manage Listings" admin section, the original posters are not able to see the ads that have expired or become inactive.

I would like the ads to remain "Inactive" after expiration so that posters still see their old ads when they login so renewal is possible.

I still want to manually block an ad if it is unsuitable.

Can code be added, modified or commented out/deleted?

Thank you.

This post should be in the general help section.
Apologies to the forum moderators.
« Last Edit: July 02, 2018, 05:53:32 pm by aguy »

digitalsense

  • Jr. Member
  • **
  • Posts: 94
  • Hello there!
Re: Is it possible to disable ads becoming "blocked" after "expiry"?
« Reply #1 on: July 02, 2018, 10:47:46 am »
Hi

Wanted to ask you does your expired are blocked by default

below code might help:

function make_item_inactive_expired()
{
$todayDate = date('Y-m-j');
   
  Item::newInstance()->dao->query(sprintf("UPDATE %st_item SET b_active = 0 WHERE dt_expiration < '$todayDate' && b_premium = 0", DB_TABLE_PREFIX)); 

}

osc_add_hook('cron_daily', 'make_item_inactive_expired'); //to run it daily
osc_add_hook('cron_hourly', 'make_item_inactive_expired'); //to run it hourly

aguy

  • Newbie
  • *
  • Posts: 8
Re: Is it possible to disable ads becoming "blocked" after "expiry"?
« Reply #2 on: July 02, 2018, 04:30:18 pm »
Hi Digitalsense,
By default in Bender, the ads become inactive after expiring but then change to blocked in the admin Manage Listings section.

Only the admin can see the listings when this happens.
I need users to see their expired ads when they login.
Otherwise they cannot renew the ads.

Where does this code go?
Code: [Select]
function make_item_inactive_expired()
{
$todayDate = date('Y-m-j');
   
  Item::newInstance()->dao->query(sprintf("UPDATE %st_item SET b_active = 0 WHERE dt_expiration < '$todayDate' && b_premium = 0", DB_TABLE_PREFIX));

}

Where does this code go?
Code: [Select]
osc_add_hook('cron_daily', 'make_item_inactive_expired'); //to run it daily
osc_add_hook('cron_hourly', 'make_item_inactive_expired'); //to run it hourly

Not being a coder, I need some direction.

Thanks for taking the time to reply.

Regards.

digitalsense

  • Jr. Member
  • **
  • Posts: 94
  • Hello there!
Re: Is it possible to disable ads becoming "blocked" after "expiry"?
« Reply #3 on: July 02, 2018, 10:33:59 pm »
Hi Digitalsense,
By default in Bender, the ads become inactive after expiring but then change to blocked in the admin Manage Listings section.

Only the admin can see the listings when this happens.
I need users to see their expired ads when they login.
Otherwise they cannot renew the ads.

Where does this code go?
Code: [Select]

function make_item_inactive_expired()
{
$todayDate = date('Y-m-j');
   
  Item::newInstance()->dao->query(sprintf("UPDATE %st_item SET b_active = 0 WHERE dt_expiration < '$todayDate' && b_premium = 0", DB_TABLE_PREFIX));

}

Where does this code go?
Code: [Select]
osc_add_hook('cron_daily', 'make_item_inactive_expired'); //to run it daily
osc_add_hook('cron_hourly', 'make_item_inactive_expired'); //to run it hourly

Not being a coder, I need some direction.

Thanks for taking the time to reply.

Regards.

the above code goes to functions.php file of your theme

And if you block ads manually than it wont be visible to users by if they are expired they will be visible to users once logged in

aguy

  • Newbie
  • *
  • Posts: 8
Re: Is it possible to disable ads becoming "blocked" after "expiry"?
« Reply #4 on: July 02, 2018, 11:15:24 pm »
Thanks for the quick answer!
I'll give it a go and update you with the results.
It might take a day or so to see if the blocking is disabled when ads expire unless the modified function settings take effect immediately after saving.
This is not someting I know.

aguy

  • Newbie
  • *
  • Posts: 8
Re: Is it possible to disable ads becoming "blocked" after "expiry"?
« Reply #5 on: July 02, 2018, 11:44:27 pm »
Hi Digitalsense,
By default in Bender, the ads become inactive after expiring but then change to blocked in the admin Manage Listings section.

Only the admin can see the listings when this happens.
I need users to see their expired ads when they login.
Otherwise they cannot renew the ads.

Where does this code go?
Code: [Select]

function make_item_inactive_expired()
{
$todayDate = date('Y-m-j');
   
  Item::newInstance()->dao->query(sprintf("UPDATE %st_item SET b_active = 0 WHERE dt_expiration < '$todayDate' && b_premium = 0", DB_TABLE_PREFIX));

}

Where does this code go?
Code: [Select]
osc_add_hook('cron_daily', 'make_item_inactive_expired'); //to run it daily
osc_add_hook('cron_hourly', 'make_item_inactive_expired'); //to run it hourly

Not being a coder, I need some direction.

Thanks for taking the time to reply.

Regards.

the above code goes to functions.php file of your theme

And if you block ads manually than it wont be visible to users by if they are expired they will be visible to users once logged in

Once the snippet was added a test blocked ad changed from "Blocked" to "Expired".
I was able to see the ad and still able to block it manually.

You have saved me a ton of grief by sharing a solution.

Thank you.

=============================================================================================

*Update*

Seems that "Inactive" ads are not appearing in the "Latest Listings" page even to a logged in user.

I have to manually "Activate" the ad.
Once that's done the ad appears on the homepage.

The ad should appear after being renewed by the user.

So close.
« Last Edit: July 03, 2018, 12:05:56 am by aguy »

digitalsense

  • Jr. Member
  • **
  • Posts: 94
  • Hello there!
Re: Is it possible to disable ads becoming "blocked" after "expiry"?
« Reply #6 on: July 03, 2018, 11:26:40 am »
By default

Blocked and Inactive ads wont be visible  on the home or search page or anywhere.

the ads which are expired or inactive will be visible only to user who has posted the items under their listing.

aguy

  • Newbie
  • *
  • Posts: 8
Re: Is it possible to disable ads becoming "blocked" after "expiry"?
« Reply #7 on: July 03, 2018, 04:15:21 pm »
After more testing, users now see "Expired" and "Inactive" ads which is perfect.

The user can now renew their "Expired" ad without issues.

Only renewed "Expired" ads become visible on the homepage "Latest Listings".

If for some reason the ad status is "Inactive" only the admin knows it.

When a user tries to renew an "Inactive" ad, the process completes successfully but the renewed ad does not appear in the "Latest Listings" page (Homepage).

In this case the admin has to manually convert the ad to "Expired" or activate the "Inactive" ad for the user.

This could be problematic if this affects too many users.

Is there a way to prevent ads from becoming "Inactive" and go directly to ""Expired"?

Or will your snippet work as is?

Have not used it enough to know, nor do I understand the snippet to attempt modifying it myself.

Apologies for the redundent questions but not being a coder forces me to ask for clarification.

Thanks again for your generous assistance.