InMotion Hosting Support Center

How can I customize the Banned IP message in Drupal 7?

Category: Drupal

2012-03-26 11:04 am EST

Hits: 1,940
I was reading your article and was wondering how you could customize the message “Sorry, has been banned.” I'm a web developer and would like to customize that message. Do you know how?

You must login before you can ask a follow up question.

You must login before you can submit an answer.



Tim S.
9,967 Points
2012-03-26 11:22 am EST
Hi mikeb,

Thanks for posting your question. I'm more than happy to assist you. The code to check to see if the IP address is banned is handled in the /includes/ file. You can edit the message in the code in the file to whatever you'd like. Here's the code snippet to look for in that file:

* Handles denied users.
* @param $ip
* IP address to check. Prints a message and exits if access is denied.
function drupal_block_denied($ip) {
// Deny access to blocked IP addresses - t() is not yet available.
if (drupal_is_denied($ip)) {
header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
print 'Sorry, ' . check_plain(ip_address()) . ' has been banned.';

Notice, the line:

print 'Sorry, ' . check_plain(ip_address()) . ' has been banned.';

You simply need to edit this line to whatever you'd like the banned IP address message to be.

If you need further assistance please feel free to contact us.


Tim S

You must login before you can post a comment about this answer.

I came across this post while looking for information on how to translate the ip banned message in question. I hope you don't mind if I ask a couple of questions.

1) Would it be possible use settings.php in the theme to achieve the same result (instead of changing a core file)?

2) How would one make this message translatable?

Thank you in advance for any insight that you could provide!
6 Points
2014-03-30 8:51 pm EST
Hello jorgemare,
Unfortunately, I am unaware of a solution to change this using a theme or making it translatable. You may, however. be able to develop a custom plugin that overrides this.
11,186 Points
2014-03-31 8:51 am EST

Thank you for they reply.

Will see if I can find a solution that does not require hacking core, and will share it here.

6 Points
2014-04-01 4:31 am EST
Like this Question?

Support Center Login

Social Media Login

Social Login Joomla

Related Articles

Need more Help?


Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail:
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!