Title: Plugin redirecting and exiting WP_CLI
Last modified: January 30, 2026

---

# Plugin redirecting and exiting WP_CLI

 *  Resolved [Menno van den Ende](https://wordpress.org/support/users/mennoll/)
 * (@mennoll)
 * [4 months, 1 week ago](https://wordpress.org/support/topic/plugin-redirecting-and-exiting-wp_cli/)
 * Dear developer,
 * I’ve got an issue where the plugin is attempting to perform a redirect while 
   running WP-CLI commands.
 * This will cause a redirect and most important an `exit;` to happen, which stops
   all CLI commands from running.
 * To prevent this, inside the `IP2LocationRedirection::redirect()` function, a 
   check should be added to see if WP-CLI is currently running a command.
 *     ```wp-block-code
       	public function redirect()	{		// Disable redirection for WP-CLI		if ( defined( 'WP_CLI' ) && WP_CLI ) {			return;		}				// Rest of the code here ...	}
       ```
   
 * If a CLI command is running, the function should be aborted, and no redirect 
   logic should be triggered.
 * Would you be able to see if this fix can be applied in a new plugin version?
   
   Thanks in advance!
 * Kind regards,
   Menno
    -  This topic was modified 4 months, 1 week ago by [Menno van den Ende](https://wordpress.org/support/users/mennoll/).
      Reason: politeness

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

 *  Plugin Support [wpip2location](https://wordpress.org/support/users/wpip2location/)
 * (@wpip2location)
 * [4 months, 1 week ago](https://wordpress.org/support/topic/plugin-redirecting-and-exiting-wp_cli/#post-18804111)
 * Thank you. It has been applied into the version 1.38.0.
 *  Thread Starter [Menno van den Ende](https://wordpress.org/support/users/mennoll/)
 * (@mennoll)
 * [4 months, 1 week ago](https://wordpress.org/support/topic/plugin-redirecting-and-exiting-wp_cli/#post-18804134)
 * Wow that’s extremely fast, thank you so much! Have a nice weekend!

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

You must be [logged in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fplugin-redirecting-and-exiting-wp_cli%2F%3Foutput_format%3Dmd&locale=en_US)
to reply to this topic.

 * ![](https://ps.w.org/ip2location-redirection/assets/icon-128x128.png?rev=2121920)
 * [IP2Location Redirection](https://wordpress.org/plugins/ip2location-redirection/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ip2location-redirection/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ip2location-redirection/)
 * [Active Topics](https://wordpress.org/support/plugin/ip2location-redirection/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ip2location-redirection/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ip2location-redirection/reviews/)

## Tags

 * [cli](https://wordpress.org/support/topic-tag/cli/)
 * [exit](https://wordpress.org/support/topic-tag/exit/)
 * [IP](https://wordpress.org/support/topic-tag/ip/)
 * [redirect](https://wordpress.org/support/topic-tag/redirect/)
 * [wp-cli](https://wordpress.org/support/topic-tag/wp-cli/)
 * [wpcli](https://wordpress.org/support/topic-tag/wpcli/)

 * 2 replies
 * 2 participants
 * Last reply from: [Menno van den Ende](https://wordpress.org/support/users/mennoll/)
 * Last activity: [4 months, 1 week ago](https://wordpress.org/support/topic/plugin-redirecting-and-exiting-wp_cli/#post-18804134)
 * Status: resolved