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

Category: Drupal

mikeb
Asked:
2012-03-26 3:04 pm

Hits: 746
I was reading your article http://www.inmotionhosting.com/support/website/drupal/blocking-a-specific-ip-address-in-drupal and was wondering how you could customize the message “Sorry, 141.0.10.182 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.

OTHER ANSWERS

0

Tim S.
2012-03-26 3:22 pm
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/bootstrap.inc 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.';
exit();
}
}



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.

Thanks!

Tim S

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

Like this Question?

Need more Help?

Search

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: support@InMotionHosting.com
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!