Implementation Lesson 35: Manually Activate Scheduled Auctions in the Flipnzee Auctions Plugin
In the previous lesson, we added Auction Start and Auction End scheduling fields to our auctions. However, simply storing these dates in the database is not enough. The plugin also needs a mechanism to activate auctions when their scheduled start time arrives.
In this implementation lesson, we built the first version of that mechanism by adding a Manual Auction Activation feature.
Although the final version will eventually run automatically using WordPress Cron, implementing a manual activation tool first makes development, testing, and debugging much easier.
What We Built
By the end of this lesson, our plugin can:
- Store scheduled auction start dates.
- Compare scheduled start dates with the current WordPress time.
- Activate eligible auctions.
- Provide an administrator button to run the activation process manually.
- Lay the foundation for future automation.
Step 1: Create the Activation Function

Inside class-auction-manager.php, we created a new method:
public static function activate_scheduled_auctions()
This method:
- Retrieves the current WordPress time.
- Searches for auctions whose:
- status is draft
- Auction Start has passed
- Updates their status to:
active
Step 2: Use a Single SQL UPDATE Query
Instead of loading every auction into PHP, we used one efficient SQL query.
The query updates every matching auction in one operation.
Benefits include:
- Better performance
- Cleaner code
- Easier maintenance
- Scales well for hundreds or thousands of auctions
Step 3: Add a Dashboard Button
Inside the Flipnzee Auctions dashboard, we added a new button:
Activate Scheduled Auctions
Clicking this button executes the activation process immediately.
This allows us to verify our scheduling logic before introducing automatic background processing.
Step 4: Register a Secure Admin Action
We registered a custom admin action using:
admin_post_flipnzee_activate_scheduled_auctions
The handler performs several important tasks:
- Capability check
- Nonce verification
- Calls the activation function
- Redirects back to the dashboard
This follows standard WordPress security practices.
Step 5: Add Nonce Protection
Every activation request includes a WordPress nonce.
Before processing, the plugin verifies that the request originated from the WordPress administration area.
This prevents Cross-Site Request Forgery (CSRF) attacks.
Step 6: Test the Feature
Testing involved:
- Creating multiple auctions
- Assigning different Auction Start dates
- Saving them
- Clicking Activate Scheduled Auctions
- Verifying database values using phpMyAdmin
This confirmed that our activation logic was executing correctly.
Debugging an Unexpected Issue
During testing, auctions were not changing from Draft to Active, even though their scheduled start times had already passed.
Instead of assuming the SQL query was incorrect, we debugged the process step by step.
Checking the Database

Using phpMyAdmin, we verified that:
- Auction Start values were stored correctly.
- Auction End values were stored correctly.
- Auction status remained draft.
This confirmed that the data itself was not the problem.
Verifying the SQL Logic
Next, we reviewed the SQL UPDATE statement.
The query correctly selected auctions where:
- status = draft
- auction_start <= current WordPress time
No issues were found in the SQL itself.
Inspecting the Current WordPress Time

To isolate the issue, we temporarily added:
wp_die( current_time( 'mysql' ) );
This allowed us to display the exact time that WordPress was using during the activation process.
The output revealed that WordPress was using a different timezone than expected.
Root Cause
The activation logic depended on:
current_time( 'mysql' )
while the stored auction schedule had been entered using local time.
As a result:
- Auction Start appeared to be in the future.
- The SQL condition never matched.
- No auctions were activated.
The activation function itself was working correctly.
Lessons Learned
This debugging session reinforced several important development principles.
Instead of immediately changing the SQL query, we:
- Verified the stored database values.
- Confirmed the SQL logic.
- Checked the current application time.
- Identified the real source of the problem.
This systematic approach saved considerable time and prevented unnecessary code changes.
Why We Built Manual Activation First
Eventually, auctions should activate automatically.
However, during development, a manual activation tool provides several advantages:
- Easier debugging
- Immediate testing
- No dependency on WP-Cron
- Faster development cycle
Once the activation logic has been thoroughly tested, replacing the manual button with automatic scheduling becomes straightforward.
What’s Next?
In the next lesson, we’ll complete the scheduling workflow by implementing Manual Auction Closing.
Auctions whose scheduled end time has passed will automatically transition from Active to Closed, laying another important foundation for a production-ready auction platform.
Download Source Code
Download the starting version before this lesson:
โฌ Download Plugin (After Lesson 34) (0 downloads )Download the completed version after implementing this lesson:
โฌ Download Plugin (After Lesson 35) (0 downloads )












