Title: Copy and paste this code into your plugin please.
Last modified: August 30, 2016

---

# Copy and paste this code into your plugin please.

 *  [elliotsabitov](https://wordpress.org/support/users/elliotsabitov/)
 * (@elliotsabitov)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/copy-and-paste-this-code-into-your-plugin-please/)
 * Hello,
 * I am using your plugin and I wanted to submit an improvement. I edited a few 
   lines of code in your plugin’s password-protected.php file.
 * I changed:
 *     ```
       function allow_ip_addresses( $bool ) {
   
       		$ip_addresses = $this->get_allowed_ip_addresses();
   
       		if ( in_array( $_SERVER['REMOTE_ADDR'], $ip_addresses ) ) {
       			$bool = false;
       		}
   
       		return $bool;
   
       	}
       ```
   
 * to this:
 *     ```
       function allow_ip_addresses( $bool ) {
   
       		$ip_addresses = $this->get_allowed_ip_addresses();
   
       		foreach($ip_addresses as $ip){
       			if ( $_SERVER['REMOTE_ADDR'] === gethostbyname($ip) ) {
       				$bool = false; break;
       			}
       		}
   
       		return $bool;
   
       	}
       ```
   
 * What this does, is it allows users to whitelist not only IPs but also other strings.
   For example, I am using No-IP for Dynamic DNS, in other words, my routers IP 
   address may change, due to ISP, and I have a DynDNS set up so that xys.ddns.net
   will end up at my IP. So gethostbyname() will check if it’s a domain name or 
   something that resolves an IP, and work if it is and returns an IP that matches
   users IP.
 * [https://wordpress.org/plugins/password-protected/](https://wordpress.org/plugins/password-protected/)

The topic ‘Copy and paste this code into your plugin please.’ is closed to new replies.

 * ![](https://ps.w.org/password-protected/assets/icon-128x128.gif?rev=2824217)
 * [Password Protected — Lock Entire Site, Pages, Posts, Categories, and Partial Content](https://wordpress.org/plugins/password-protected/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/password-protected/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/password-protected/)
 * [Active Topics](https://wordpress.org/support/plugin/password-protected/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/password-protected/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/password-protected/reviews/)

## Tags

 * [dynamic-dns](https://wordpress.org/support/topic-tag/dynamic-dns/)
 * [dyndns](https://wordpress.org/support/topic-tag/dyndns/)
 * [password](https://wordpress.org/support/topic-tag/password/)
 * [protected](https://wordpress.org/support/topic-tag/protected/)

 * 0 replies
 * 1 participant
 * Last reply from: [elliotsabitov](https://wordpress.org/support/users/elliotsabitov/)
 * Last activity: [10 years, 11 months ago](https://wordpress.org/support/topic/copy-and-paste-this-code-into-your-plugin-please/)
 * Status: not resolved