Answers.Body: <p>The cron job needs to call <code>wp</code>  not <code>civicrm/wp-cli/cv.phar</code></p>
  <p>I'd suggest <code> */5 * * * * /opt/cpanel/ea-php73/root/usr/bin/php wp cv api job.process_mailing --user=admin --path=/home/the_website/civi.the_website.net/ auth=0</code></p>
  <p>In place of <code>wp</code> you may need to full path to the wp-cli script on the server.  I have to install this myself on most cpanel servers.  Instructions are here: <a href="https://wp-cli.org/#installing" rel="nofollow noreferrer">https://wp-cli.org/#installing</a></p>
  <p>CiviCRM's documentation is at <a href="https://docs.civicrm.org/sysadmin/en/latest/setup/jobs/#wp-cli" rel="nofollow noreferrer">https://docs.civicrm.org/sysadmin/en/latest/setup/jobs/#wp-cli</a></p>
  <p>Added from Comments:</p>
  <blockquote>
  <p>that's what it was! I restored the /home/user_dir/subdomain.domain.net/wp-content/uploads/civicrm &gt; edited the civicrm.settings.php to reflect a new password without special characters &gt; changed the db user password to that and it came right up. Warning to any and all, no special characters in your mysql / maria db password!</p>
  </blockquote>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-06-24T14:14:57.317Z
Answers.Text: Well...I properly installed wp-cli and cv in my /local/usr/bin, added chomd +x so it will be executable then tried this command as the web user:
  
  '/opt/cpanel/ea-php73/root/usr/bin/php wp cv api job.process_mailing --user=admin --path=/home/the_website/the.subdomain.net/
  Fatal error: Uncaught CRM_Core_Exception: [unauthorized: Authorization failed
  
    thrown in /home/the_website/the.subdomain.net/wp-content/plugins/civicrm/civicrm/Civi/API/Kernel.php on line 232'
  
  ...but still get the error.  I'm at a loss.  Any other thoughts?
  
  The editor text on this site is wack
Answers.UserDisplayName: A Civi Admin Kinda
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-06-25T15:10:04.230Z
Answers.Text: I'd try some basic commands  `wp cv sql-conf` and `wp cv cache-clear`  and see what that says. I'd also look at file permissions, and see that Directories are 755 and files are 644.   I'd also call WP with full path Just in case....   This is from a cpanel server `/opt/cpanel/ea-php74/root/usr/bin/php /usr/local/bin/wp --user=civicron --url=https://example.org --path=/home/example.org/public_html --timezone="America/New_York" civicrm api job.execute auth=0`
Answers.UserDisplayName: Kevin Cristiano
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-06-25T15:10:19.273Z
Answers.Text: That snippet runs all scheduled jobs , for you I'd try `/opt/cpanel/ea-php74/root/usr/bin/php /usr/local/bin/wp --user=civicron --url=https://example.org --path=/home/example.org/public_html --timezone="America/New_York" civicrm api job.process_mailing auth=0`
Answers.UserDisplayName: Kevin Cristiano
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-06-26T13:09:34.337Z
Answers.Text: No go, same set of errors about the api authorization.  I fiddled with the code you suggested like last time too all with the same error.  I'm going to setup a brand new LAMP > restore from backup with sql dump and reinstall the plugin.  I suspect it has something to do with CPanel, the user running the cron or who knows.  Maybe I'll get different results on a stand alone host than a shared host.  Thanks for pitching in and offering to assist.
Answers.UserDisplayName: A Civi Admin Kinda
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-06-26T22:44:58.600Z
Answers.Text: Still pulling my hair out. Everything seems to be in the ~/civi.thewebsite.com/wp-content/uploads/civi/civicrm.settings.php and maybe the mysql connection string got mangled?  The reason I think this is because the password to the db has "special characters" in it from the default WP install.  ~?#.  I noticed a password like this:  1~ab?3#4, gets turned into this:  1%1B%3%...or something like that.  Like, its mangling special characters into % characters and messing with the case of the letter in once instance and adding some.  Weird and odd.  I tried to manually edit to no avail. Still trying
Answers.UserDisplayName: A Civi Admin Kinda
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-06-26T23:52:16.127Z
Answers.Text: ^ that's what it was!  I restored the /home/user_dir/subdomain.domain.net/wp-content/uploads/civicrm > edited the civicrm.settings.php to reflect a new password without special characters > changed the db user password to that and it came right up.  Warning to any and all, no special characters in your mysql / maria db password!  Thanks!
Answers.UserDisplayName: A Civi Admin Kinda
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-06-23T17:15:34.707Z
Answers.LastActivityDate: 2023-06-27T19:06:29.137Z
Answers.LastEditDate: 2023-06-27T19:06:29.137Z
Answers.UserDisplayName: Kevin Cristiano
Body: <blockquote>
  <p>LAMP
  CentOS (CPanel)
  PHP-FPM
  PHP 7.3
  Wordpress 6.2.2
  Civi version:  civicrm-5.62.1-wordpress
  &quot;the_website&quot; = redaction from the actual user + website :)</p>
  </blockquote>
  <p>I keep running into this problem ever since we upgraded the last two times.  The last time I upgraded was because of this same error.  It works for a while then breaks seemingly for no reason!  Can I disable this api4 security check?  It's crashing the site constantly!  I had upgraded the site to PHP 8.1 but CIVI was using some kind of mail tracking header for &quot;no_reply@the_website.net&quot; to some kind of GUID_tracker@the_website.net&quot;, so I back rev'd to PHP 7.3 and that fixed the odd email problem.  Then it started crashing the site for no reason.</p>
  <pre><code>Error:
  thrown in /home/the_website/civi.the_website.net/wp-content/plugins/civicrm/civicrm/Civi/API/Kernel.php on line 232 [23-Jun-2023 06:02:15 UTC] PHP Fatal error:  Uncaught CRM_Core_Exception: [unauthorized: Authorization failed
  </code></pre>
  <p>My cron is killed that does an api call to send mail and when I tried to run the flush cache command manually just to see what it does, it also fails.</p>
  <pre><code>[~/civi.the_website.net/wp-content/plugins/civicrm/wp-cli]# /opt/cpanel/ea-php73/root/usr/bin/php ~/civi.the_website.net/wp-content/plugins/civicrm/wp-cli/cv.phar flush --cwd=/home/the_website/civi.the_website.net/
  In Kernel.php line 232:
  Authorization failed
  flush [-T|--triggers] [--level LEVEL] [--hostname HOSTNAME] [-t|--test] [-U|--user USER]
  </code></pre>
  <p>^ I also tried it with the &quot;admin&quot; user flag, same results</p>
  <p>Again, this worked fine and dandy after yesterdays upgrade and the website became usable again.  Then, after some time, perhaps with some other thing running on civi in the background, it breaks at like 6am every morning like it did on Wednesday.
  Can someone help me to turn off these security checks until these bugs get worked out?</p>
  <p>Here is my cron which calls the admin user but still fails:
  */5 * * * * /opt/cpanel/ea-php73/root/usr/bin/php ~/civi.the_website.net/wp-content/plugins/civicrm/wp-cli/cv.phar api job.process_mailing --user=admin --cwd=/home/the_website/civi.the_website.net/ &gt; ~/civi.the_website.net/cron.log</p>
  <p>I'm hurt'n LOL, thanks!</p>
  
Tags: <wordpress>
Title: Constant Authorization failed error + crashing Wordpress
ThreadText: # Constant Authorization failed error + crashing Wordpress
  
  (Asked by: username_0 on 2023-06-23)
  
  > LAMP
  > CentOS (CPanel)
  > PHP-FPM
  > PHP 7.3
  > Wordpress 6.2.2
  > Civi version: civicrm-5.62.1-wordpress
  > "the\_website" = redaction from the actual user + website :)
  
  I keep running into this problem ever since we upgraded the last two times. The last time I upgraded was because of this same error. It works for a while then breaks seemingly for no reason! Can I disable this api4 security check? It's crashing the site constantly! I had upgraded the site to PHP 8.1 but CIVI was using some kind of mail tracking header for "no\_reply@the\_website.net" to some kind of GUID\_tracker@the\_website.net", so I back rev'd to PHP 7.3 and that fixed the odd email problem. Then it started crashing the site for no reason.
  
  ```
  Error:
  thrown in /home/the_website/civi.the_website.net/wp-content/plugins/civicrm/civicrm/Civi/API/Kernel.php on line 232 [23-Jun-2023 06:02:15 UTC] PHP Fatal error:  Uncaught CRM_Core_Exception: [unauthorized: Authorization failed
  
  ```
  
  My cron is killed that does an api call to send mail and when I tried to run the flush cache command manually just to see what it does, it also fails.
  
  ```
  [~/civi.the_website.net/wp-content/plugins/civicrm/wp-cli]# /opt/cpanel/ea-php73/root/usr/bin/php ~/civi.the_website.net/wp-content/plugins/civicrm/wp-cli/cv.phar flush --cwd=/home/the_website/civi.the_website.net/
  In Kernel.php line 232:
  Authorization failed
  flush [-T|--triggers] [--level LEVEL] [--hostname HOSTNAME] [-t|--test] [-U|--user USER]
  
  ```
  
  ^ I also tried it with the "admin" user flag, same results
  
  Again, this worked fine and dandy after yesterdays upgrade and the website became usable again. Then, after some time, perhaps with some other thing running on civi in the background, it breaks at like 6am every morning like it did on Wednesday.
  Can someone help me to turn off these security checks until these bugs get worked out?
  
  Here is my cron which calls the admin user but still fails:
  \*/5 \* \* \* \* /opt/cpanel/ea-php73/root/usr/bin/php ~/civi.the\_website.net/wp-content/plugins/civicrm/wp-cli/cv.phar api job.process\_mailing --user=admin --cwd=/home/the\_website/civi.the\_website.net/ > ~/civi.the\_website.net/cron.log
  
  I'm hurt'n LOL, thanks!
  
  **Tags:** wordpress
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-06-23. Score: 1
  
  The cron job needs to call `wp` not `civicrm/wp-cli/cv.phar`
  
  I'd suggest  `*/5 * * * * /opt/cpanel/ea-php73/root/usr/bin/php wp cv api job.process_mailing --user=admin --path=/home/the_website/civi.the_website.net/ auth=0`
  
  In place of `wp` you may need to full path to the wp-cli script on the server. I have to install this myself on most cpanel servers. Instructions are here: <https://wp-cli.org/#installing>
  
  CiviCRM's documentation is at <https://docs.civicrm.org/sysadmin/en/latest/setup/jobs/#wp-cli>
  
  Added from Comments:
  
  > that's what it was! I restored the /home/user\_dir/subdomain.domain.net/wp-content/uploads/civicrm > edited the civicrm.settings.php to reflect a new password without special characters > changed the db user password to that and it came right up. Warning to any and all, no special characters in your mysql / maria db password!
  
  > **Comments:**
  > **username_0**: Well...I properly installed wp-cli and cv in my /local/usr/bin, added chomd +x so it will be executable then tried this command as the web user:  '/opt/cpanel/ea-php73/root/usr/bin/php wp cv api job.process_mailing --user=admin --path=/home/the_website/the.subdomain.net/ Fatal error: Uncaught CRM_Core_Exception: [unauthorized: Authorization failed    thrown in /home/the_website/the.subdomain.net/wp-content/plugins/civicrm/civicrm/Civi/API/Kernel.php on line 232'  ...but still get the error.  I'm at a loss.  Any other thoughts?  The editor text on this site is wack  
  > **username_1**: I'd try some basic commands  `wp cv sql-conf` and `wp cv cache-clear`  and see what that says. I'd also look at file permissions, and see that Directories are 755 and files are 644.   I'd also call WP with full path Just in case....   This is from a cpanel server `/opt/cpanel/ea-php74/root/usr/bin/php /usr/local/bin/wp --user=civicron --url=https://example.org --path=/home/example.org/public_html --timezone="America/New_York" civicrm api job.execute auth=0`  
  > **username_1**: That snippet runs all scheduled jobs , for you I'd try `/opt/cpanel/ea-php74/root/usr/bin/php /usr/local/bin/wp --user=civicron --url=https://example.org --path=/home/example.org/public_html --timezone="America/New_York" civicrm api job.process_mailing auth=0`  
  > **username_0**: No go, same set of errors about the api authorization.  I fiddled with the code you suggested like last time too all with the same error.  I'm going to setup a brand new LAMP > restore from backup with sql dump and reinstall the plugin.  I suspect it has something to do with CPanel, the user running the cron or who knows.  Maybe I'll get different results on a stand alone host than a shared host.  Thanks for pitching in and offering to assist.  
  > **username_0**: Still pulling my hair out. Everything seems to be in the ~/civi.thewebsite.com/wp-content/uploads/civi/civicrm.settings.php and maybe the mysql connection string got mangled?  The reason I think this is because the password to the db has "special characters" in it from the default WP install.  ~?#.  I noticed a password like this:  1~ab?3#4, gets turned into this:  1%1B%3%...or something like that.  Like, its mangling special characters into % characters and messing with the case of the letter in once instance and adding some.  Weird and odd.  I tried to manually edit to no avail. Still trying  
  > **username_0**: ^ that's what it was!  I restored the /home/user_dir/subdomain.domain.net/wp-content/uploads/civicrm > edited the civicrm.settings.php to reflect a new password without special characters > changed the db user password to that and it came right up.  Warning to any and all, no special characters in your mysql / maria db password!  Thanks!  
  
  ---
  
  