Title: PHP errors &#8220;Undefined array key&#8221;
Last modified: July 26, 2024

---

# PHP errors “Undefined array key”

 *  Resolved [dragon013](https://wordpress.org/support/users/dragon013/)
 * (@dragon013)
 * [1 year, 10 months ago](https://wordpress.org/support/topic/php-errors-undefined-array-key/)
 * Hello,
 * I am getting these errors when activating your plugin
 *     ```wp-block-code
       Warning: Undefined array key "HTTP_USER_AGENT" in /plugins/dark-visitors/plugin.php on line 228 Warning: Undefined array key "REQUEST_METHOD" in /plugins/dark-visitors/plugin.php on line 238
       ```
   
 * I am running PHP version 8.1
 * Any help ?
   Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [Known Agents](https://wordpress.org/support/users/gavindarkvisitors/)
 * (@gavindarkvisitors)
 * [1 year, 10 months ago](https://wordpress.org/support/topic/php-errors-undefined-array-key/#post-17914952)
 * Hi, thanks for the heads up.
 * I’ll add some checks in the code to get rid of the error, but it’s strange that
   they are undefined for you. The plugin depends on them to work.
 * Is this happening in a particular context? Or is there anything atypical about
   your server setup that you know about? This will help me track the real issue
   down.
 * Feel free to reply to our “contact at darkvisitors.com” email if you’d like faster
   support.
 * Thanks!
 *  Thread Starter [dragon013](https://wordpress.org/support/users/dragon013/)
 * (@dragon013)
 * [1 year, 9 months ago](https://wordpress.org/support/topic/php-errors-undefined-array-key/#post-17915693)
 * Hello,
 * thanks for the feedback! 
   It happens when I call wp_cron via a cron job. I guess
   because of calling it via bash and the php command like this
 *     ```wp-block-code
       php ~/<path to wordpress>/wp-cron.php 
       ```
   
 * might cause some trouble since there is no user agent or header.
 * I hope this helps!
 *  Plugin Author [Known Agents](https://wordpress.org/support/users/gavindarkvisitors/)
 * (@gavindarkvisitors)
 * [1 year, 9 months ago](https://wordpress.org/support/topic/php-errors-undefined-array-key/#post-17920716)
 * Super helpful, thank you. I think you’re right, I’ll add this fix in the next
   version.
 * All the best,
 * Gavin
 *  Plugin Author [Known Agents](https://wordpress.org/support/users/gavindarkvisitors/)
 * (@gavindarkvisitors)
 * [1 year, 9 months ago](https://wordpress.org/support/topic/php-errors-undefined-array-key/#post-17965695)
 * [@dragon013](https://wordpress.org/support/users/dragon013/) this should be fixed
   now, but let me know if not.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘PHP errors “Undefined array key”’ is closed to new replies.

 * ![](https://ps.w.org/dark-visitors/assets/icon.svg?rev=3468118)
 * [Known Agents – Track AI Bots and Crawlers, Block Scrapers, Analyze LLM Referral Traffic](https://wordpress.org/plugins/dark-visitors/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/dark-visitors/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/dark-visitors/)
 * [Active Topics](https://wordpress.org/support/plugin/dark-visitors/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/dark-visitors/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/dark-visitors/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [Known Agents](https://wordpress.org/support/users/gavindarkvisitors/)
 * Last activity: [1 year, 9 months ago](https://wordpress.org/support/topic/php-errors-undefined-array-key/#post-17965695)
 * Status: resolved