Action Scheduler in Ultimate Member
Version: Introduced in Ultimate Member 2.9.0
What is Action Scheduler?
Action Scheduler is a background processing framework built for WordPress. It allows tasks (actions) to be scheduled to run at specific times or on a recurring basis without interrupting the normal functioning of the website. Developed by Automattic, it efficiently handles scheduled emails, notifications, and other automated processes, especially when dealing with high volumes of tasks.
Key Features:
- Scheduled Actions: Enables tasks to be run at designated times or as soon as possible (asynchronous actions).
- Batch Processing: Processes large volumes of tasks efficiently in batches.
- Traceability: Logs all scheduled actions, providing visibility into their status (pending, in progress, completed, or failed).
How Ultimate Member Uses Action Scheduler
In Ultimate Member (UM), Action Scheduler is used to manage the scheduling and execution of system emails and other background tasks. It optimizes server load by queuing tasks to run at the most suitable times, rather than processing them immediately, which helps improve overall site performance.
Benefits of Action Scheduler in UM:
- Optimized Server Performance: Tasks like email sending are scheduled to run at optimal times, reducing immediate server load.
- Reliability: Ensures that tasks are executed successfully, even during high-traffic periods.
- Error Logging: Any failed tasks are logged, making it easier to identify issues and retry the actions.
How to Enable Action Scheduler in Ultimate Member
By default, Action Scheduler is disabled in UM, and its settings may not appear if there are issues with library files or initialization. Once the administrator enables it in the UM settings, it should work as expected. To enable Action Scheduler in Ultimate Member:
- Navigate to UM Settings:
- Go to the WordPress dashboard:
wp-admin > Ultimate Member > Settings
.
- Go to the WordPress dashboard:
- Access the Advanced Tab:
- Click on the Advanced tab, then select Features.
- Enable Action Scheduler:
- Find the option Action Scheduler and check the box next to Enable Action Scheduler. Enabling this option ensures tasks like system emails are scheduled to run at optimal times, which helps to reduce server load.
- Save Changes:
- Scroll down and click Save Changes to activate Action Scheduler.
What Happens When You Enable Action Scheduler?
Once enabled, certain tasks, such as system emails (e.g., registration confirmation, and password reset), will be scheduled to run at the most appropriate times. This ensures that these tasks are processed efficiently in the background, preventing unnecessary delays or strain on server resources.
How Action Scheduler Works in Ultimate Member
Action Scheduler in UM works by queuing tasks to run at scheduled times, preventing any delays or strain on the website's performance. Here's how it works:
- Scheduling and Execution:
- Tasks are queued and then processed in the background. For example, emails sent during user registration are scheduled to be sent at optimal times.
- Batch Processing:
- For large tasks, the Action Scheduler processes actions in batches of 25. Once one batch is completed, the next batch is processed until all tasks are finished. This prevents overloading the server.
- Asynchronous Loopback Requests:
- If there are still tasks to process after a batch is completed, additional asynchronous loopback requests are made to continue processing tasks in a new request.
- Housekeeping:
- Completed or cancelled tasks that are older than one month are automatically removed. Additionally, actions that take longer than 5 minutes are considered timed-out and are marked as failed, though they can be updated to "completed" if they eventually succeed.
- Error Handling:
- If any action fails, the failure is logged for troubleshooting. The administrator can view these logs and retry failed tasks.
Monitoring and Troubleshooting Scheduled Actions
Administrators can monitor and troubleshoot scheduled actions using the Scheduled Actions Administration Screen. Here’s what you can do:
- Access the Administration Screen:
- Go to wp-admin>Tools > Scheduled Actions or wp-admin>WooCommerce > Status > Scheduled Actions (if WooCommerce is installed).
- Track Action Status:
- You can filter actions by their status (Pending, In Progress, Completed, Failed).
- Example: View all actions that are currently Failed or In Progress.
- View Log Entries:
- View the log entries for any failed actions, providing detailed information on what went wrong.
- Sort and Manage Actions:
- Sort scheduled actions by:
- Hook Name
- Scheduled Date
- Claim ID
- Group Name
- This helps manage and locate specific actions efficiently.
- Sort scheduled actions by:
Advanced Configuration and Debugging
Developers can manage the Action Scheduler for advanced configurations using WP-CLI or interact with it through its API. For more detailed guidance, refer to ActionScheduler.org
Summary
Action Scheduler in Ultimate Member is a powerful tool to manage and optimize background tasks. By scheduling actions such as email sending and notifications to run at optimal times, it reduces the server load and ensures reliable task execution. With features like batch processing, error logging, and traceability, it’s an invaluable tool for administrators and developers to maintain the smooth operation of their sites.