Running and Debugging Specific WordPress Cron Hooks Manually Using WP-CLI

Thursday, December 22nd, 2022

Running and Debugging Specific WordPress Cron Hooks Manually Using WP-CLI

If your WordPress instance is configured with debugging turned off (WP_DEBUG set to false in wp-config.php) and you need to troubleshoot, debug, or run a specific WordPress cron hook or function manually, you'll find that it's pretty tough to do so.  Fortunately, I found a relatively easy way to do exactly this using WP-CLI.

Install WP-CLI

Install WP-CLI by using the below commands as root:

sudo -i
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp

Now, change into your WordPress instance vhosts directory:

cd /var/www/vhosts/{YOUR_DOMAIN}/httpdocs

Update the above path as necessary.

To run all the scheduled WordPress cron events, use this command:

wp cron event run --all --allow-root

To run a specific WordPress cron hook, use this command:

wp cron event run "NAME_OF_CRON_HOOK" --allow-root

If you need help determining the name of the cron job hook you specifically want to run or debug, install the WP Control plugin in your WordPress instance. Then visit the /wp-admin/tools.php?page=crontrol_admin_manage_page page to see a list of cron hooks and when they run.  Grab the name from the "Hook" column and update your wp cli command to run that cron event!

You can add echo statements and other code to your individual cron function plugins to better debug and troubleshoot them.

Run Everything as an Administrator in Windows 10 by Default – Same Windows 7 Behavior

Tuesday, January 28th, 2020

Run Everything as an Administrator in Windows 10 by Default – Same Windows 7 Behavior

To run everything as an administrator in Windows 10, there are several settings that must be changed.  In Windows 7, you would only have to disable UAC for the current user:

This isn't good enough in Windows 10.  You have to disable UAC for the current user AND do the following:

Run gpedit.msc to open the Local Group Policy Editor. Expand Computer Configuration, Windows Settings, Security Settings, Local Policies, and Security Options. Four settings need to be updated:

  1. Set "User Account Control: Behavior of the elevation prompt for administrators in Admin Approval Mode" to Elevate without prompting.
  2. Set "User Account Control: Detect application installations and prompt for elevation" to Disabled.
  3. Set "User Account Control: Run all administrators in Admin Approval Mode" to Disabled.
  4. Set "User Account Control: Only elevate UIAccess applications that are installed in secure locations" to Disabled.

The LGPE automatically saves all changes, so exit it and reboot.

Please read more here:

https://superuser.com/questions/1002262/run-applications-as-administrator-by-default-in-windows-10