Title: Block IP address from php code
Last modified: December 1, 2020

---

# Block IP address from php code

 *  Resolved [lexdubyna](https://wordpress.org/support/users/lexdubyna/)
 * (@lexdubyna)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/block-ip-address-from-php-code/)
 * Hello!
    Is there a way to block IP address from php code? I see there are `wordfence::
   importSettings()` and `wordfence::whitelistIP()` but is there something like `
   wordfence::blockIP($IP)` (or any other option) that can be used in code?

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

 *  Plugin Support [wfpeter](https://wordpress.org/support/users/wfpeter/)
 * (@wfpeter)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/block-ip-address-from-php-code/#post-13732719)
 * Hi [@lexdubyna](https://wordpress.org/support/users/lexdubyna/), thanks for your
   query.
 * The documentation on the Wordfence API functions that you mention is the extent
   of what can currently be called.
 * Are you coding a custom condition outside of Wordfence’s current feature set 
   that would cause an IP to be blocked? I am more than happy to submit a development
   request for your condition (_or just the wordfence::blockIP() API function_) 
   you wish to use. As we have channels internally where requests are discussed,
   they’re all taken seriously with pros and cons weighed up for potentially scheduling
   into future updates.
 * Thanks,
 * Peter.
 *  Thread Starter [lexdubyna](https://wordpress.org/support/users/lexdubyna/)
 * (@lexdubyna)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/block-ip-address-from-php-code/#post-13733731)
 * Hello [@wfpeter](https://wordpress.org/support/users/wfpeter/)
    Yes, that is 
   exactly what I am trying to do – `coding a custom condition outside of Wordfence’s
   current feature set that would cause an IP to be blocked` I would be very grateful
   if you submit the development request for this functionality. Thank you!
 *  Plugin Support [wfpeter](https://wordpress.org/support/users/wfpeter/)
 * (@wfpeter)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/block-ip-address-from-php-code/#post-13740026)
 * Hi [@lexdubyna](https://wordpress.org/support/users/lexdubyna/),
 * I have submitted that request for you, naturally I can’t promise any timescales
   or inclusion on here but please be aware that it **will** be discussed.
 * Thanks again,
 * Peter.
 *  [Loren](https://wordpress.org/support/users/ljbrown/)
 * (@ljbrown)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/block-ip-address-from-php-code/#post-13831632)
 * This is an excellent feature we need now as well.

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

The topic ‘Block IP address from php code’ is closed to new replies.

 * ![](https://ps.w.org/wordfence/assets/icon.svg?rev=2070865)
 * [Wordfence Security - Firewall, Malware Scan, and Login Security](https://wordpress.org/plugins/wordfence/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wordfence/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wordfence/)
 * [Active Topics](https://wordpress.org/support/plugin/wordfence/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wordfence/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wordfence/reviews/)

## Tags

 * [blocking](https://wordpress.org/support/topic-tag/blocking/)
 * [IP](https://wordpress.org/support/topic-tag/ip/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * 4 replies
 * 3 participants
 * Last reply from: [Loren](https://wordpress.org/support/users/ljbrown/)
 * Last activity: [5 years, 5 months ago](https://wordpress.org/support/topic/block-ip-address-from-php-code/#post-13831632)
 * Status: resolved