Listing deadlines don't work, and neither do featured listing deadlines

I always have this problem that the deadlines in the listing calendar don’t work. Featured listing always remain featured, and free listing do not expire. I insert the code you told me to insert into the Functions.php file, but it doesn’t work.

add_action(
	'init',
	function(){
		remove_action( 'hivepress/v1/events/hourly', [ hivepress()->listing, 'expire_listings' ] );
	}
);

add_action( 
	'hivepress/v1/events/hourly',  
	function(){
		// Get expired listings.
		$expired_listings = \HivePress\Models\Listing::query()->filter(
			[
				'status__in'        => [ 'pending', 'publish' ],
				'expired_time__lte' => time(),
			]
		)->limit( 100 )->get();

		// Update expired listings.
		foreach ( $expired_listings as $listing ) {

			// Update status.
			$listing->set_status( 'draft' )->save_status();

			// Send email.
			$user = $listing->get_user();

			if ( $user ) {
				( new \HivePress\Emails\Listing_Expire(
					[
						'recipient' => $user->get_email(),

						'tokens'    => [
							'user'          => $user,
							'listing'       => $listing,
							'user_name'     => $user->get_display_name(),
							'listing_title' => $listing->get_title(),
							'listing_url'   => hivepress()->router->get_url( 'listing_edit_page', [ 'listing_id' => $listing->get_id() ] ),
						],
					]
				) )->send();
			}
		}

		// Get storage period.
		$storage_period = absint( get_option( 'hp_listing_storage_period' ) );

		if ( $storage_period ) {

			// Delete stored listings.
			\HivePress\Models\Listing::query()->filter(
				[
					'status'            => 'draft',
					'expired_time__lte' => time() - DAY_IN_SECONDS * $storage_period,
				]
			)->trash();
		}

		// Get featured listings.
		$featured_listings = \HivePress\Models\Listing::query()->filter(
			[
				'status__in'         => [ 'draft', 'pending', 'publish' ],
				'featured_time__lte' => time(),
			]
		)->get();

		// Update featured listings.
		foreach ( $featured_listings as $listing ) {
			$listing->fill(
				[
					'featured'      => false,
					'featured_time' => null,
				]
			)->save( [ 'featured', 'featured_time' ] );
		}
	}
);

Hi,

If I understood you correctly, the listings do not expire and do not lose their featured status? If fo, Please disable third-party plugins and customizations (if there are any) and check if this issue persists. If you use a caching plugin, make sure that caching is disabled for logged-in users. Also, please navigate to WP Dashboard > Tools > Scheduled Actions and check if there is a failed action there hivepress/v1/events/hourly

Yes, you understood perfectly. I deactivated the plugin that might be conflicting. The scheduled actions are in Woocommerce and are two failed actions. 1) hivepress/v1/events/hourly 2) Many like hivepress/v1/events/twicedaily.

Completed some: 1) hivepress/v1/events/twicedaily
2) hivepress/v1/events/daily

Hi,

If hourly failed, please check more details about why it failed, maybe there are error logs. Also, if you manually click Run on hourly in Pending actions, is the listing expired with an expired date?

This is the last error of the system, but there are others

  1. 2024-05-02 14:27:31 +0000
    azione creata
  2. 2024-05-02 14:28:25 +0000
    azione avviata via WP Cron
  3. 2024-05-02 14:28:35 +0000
    arresto imprevisto: errore PHP irreversibile Allowed memory size of 2147483648 bytes exhausted (tried to allocate 20480 bytes) in /home/u341579782/domains/cercatutto.online/public_html/wp-includes/class-wpdb.php alla riga 2320

If you want to understand better I can send you temporary access to my wordpress

Hi,

According to the error, it gets the failed status because there is not enough memory. Try disabling third-party plugins and check in two hours if this listing expires (if there is no such listing with an expired date, create one such test listing). Also, please provide more details, how many listings do you have in total?

Ok I deactivate the plugins. There are around 8000 listings inside. But how can I create a new listing if the deadlines are in days and not hours? I have to make a featured listing expiring tomorrow

I deactivated almost all plugins, but it’s not working. Actions hivepress/v1/events/hourly all failed

Hi,

It’s okay, it’s already indicated in the dates, it just depends on when the listing was published, it’s counted if you specify the period in days from the publication, if you manually specify the date, then from midnight. Most likely, this is a memory issue, if you have a lot of listings that are about to expire, then try leaving only one listing and see if everything works.

Hi, I actually don’t have many listings that expire all together on the same day because I started adding the listing deadlines recently.
The featured listings are few but they don’t expire anyway.
The listings in total are approximately 8000.
I do not know what to do.

Update: I tried with just one expiring listing and it still doesn’t work. I honestly don’t know what to do anymore, I deactivated all the third party plugins that could cause problems and I still haven’t solved it

Hi,

Please send temporary WP access to support@hivepress.io with details for reproducing this issue, and we’ll check it (please send only the link, without login and password). You can create a temporary access link using this plugin Temporary Login Without Password – WordPress plugin | WordPress.org.

Done.

Hi,

Unfortunately, we did not receive a link from you. If you sent it automatically, please send it manually and be sure to include a link to this topic.

Ok, sent again to support@hivepress.io

News?

Hi,

We have replied to your email, please check it.

me too, check it