By the time admin_init rolls around you should know if you’re doing AJAX or not. If you’re not, then check the IP. Keep in mind that anyone can fake that number.
add_action('admin_init', function() {
if(defined('DOING_AJAX') && DOING_AJAX) {
return; // ignore ajax
};
$ip = $_SERVER[ 'REMOTE_ADDR' ];
if($ip !== '10.0.0.0') {
wp_die(__('You are not allowed to access this part of the site'));
}
});
Related Posts:
- I found this in a plugin. What does it do? is it dangerous?
- How to properly secure my WordPress installation?
- Questions about brute force attacks on the admin username, coming from amazon IP addresses
- Why Better WP security plugin returns 418 I’m a Teapot “error”?
- Weird problems after recovery from security breach
- Escape when echoed
- Preventing BFA in WordPress without using a plugin
- Why isn’t admin_notices displaying my text? [Simple Plugin, Beginner]
- problems with wordpress and php version 5.3.3-1
- WordPress takes too much time (100 seconds) to load – Front end and back end
- WordPress on AWS with ELB
- How to make multiple admin pages for one plugin?
- How can i force wp-admin to use 2-column dashboard layout? [closed]
- Is this plugin safe to run?
- WP Insert Post If user refreshes override new post
- 404 errors when updating options in admin dashboard
- Can I disable xml-rpc by setting it to false?
- WordPress fatal error from php protocol codes
- How can we get this dynamically as this folder may not be by the same name always → wp-admin
- Calling PHP function with AJAX
- WordPress Plugin PHP Not Calling Function
- Is admin section completely customizable in terms of styling?
- Optimized PHP & WordPress settings for speed/performance?
- Admin login substantially slower on production server
- How to add php stylesheet to admin section instead of admin_head hook
- Allow users to download media files directly from Amazon S3 (AWS plugin)
- Fast Tranfering my WordPress site to another server
- How to debug periodic performance issue
- How to rename files during upload to a random string?
- Allow direct access to files/folders within WordPress to replace wp-admin
- Getting 504 Gateway Timeout Error on AWS Server! [closed]
- PHP FATAL ERROR
- Stop the user if login from the cookies
- Secure way to add JS Script to WordPress filesystem
- redirect logged users to custom front-end insetad of wp-admin
- Security checking in meta_box save is reluctant?
- How do you remove plugin edit option?
- Scope for PHP Variables Assigned in functions.php or a plugin
- Should you escape hardcoded URLs?
- add_meta_box (Will display only in specific page admin WordPress)
- Cannot access wp-admin after disabling all plugin
- Make specific products accessible only to a user role in WooCommerce
- force customers to add only single item to card per purchase EDD [closed]
- Undefined property: WP_Post_Type::$ID
- Plugin exceeds memory limit
- How to get post URL in the_content filter?
- How to remove xmlns on language_attributes()?
- How to write one comment and publish on every post using database or plugin?
- Add a plugin before main container
- Shortcode to generate and save password in a file
- How to get subscription key or id using Woocommerce Subscriptions [closed]
- How to get member list based on role by using buddypress?
- I don’t understand how this parameter works..?
- Why wp_mail() function isn’t sending any emails and displaying ‘0’ in Chrome ‘Network’ response
- How to initialize something in unit test before the init hook being called?
- Function to prevent users from trashing comments
- How to Sort the Favorite Plugins Screen Alphabetically?
- Hide extra menus from WordPress Dashboard
- Missing argument 3 for wp_register_sidebar_widget()
- Make id column as AUTO INCREMENT on plugin activation
- How to Include a Loop Template File in a Plugin
- Write to / remove from default .htaccess file from plugin?
- How to provide a plugin which requires CMB2 (plugin dependencies)?
- Admin username and password
- ‘wp_login’ action hook not working with wp-login.php file
- Update Option Error: Notice: Undefined index
- How can I display a contact form for out of stock products in WooCommerce?
- Pass a php string to a javascript variable
- get shortcode value
- How to get number of Affected rows from wordpress dbDelta() function
- Show price with Geo IP location
- WordPress Ajax Callback
- Add category to body class
- The called constructor method for WP_Widget in GFWidget is deprecated since version 4.3.0! Use
- Plugin Development sqlite or WordPress’ database
- How to review WordPress website php version compatibility?
- printf – problem to understand code
- Custom Post Type Plugin not loading category template and loading 404 instead
- Sending email from inside a plugin using PHP PEAR
- Evaluations of two wordpress security plans against php code injection attack
- Auto delete WordPress users according to time
- How to cancel WordPress’ action/filter when using OOP with anonymous callback
- WordPress Plugin Page is Loading in Admin Content Container Instead of Separate Page
- How to trigger $_GET request within admin plugin page?
- Wp favorite posts get user favorites in profile using buddypress [closed]
- 404 Error on Activate / Deactivate Plugin
- Storing Options in a Shortcode
- How to generate video out of images via WordPress plugin
- How can I make uploaded images in the editor load with HTTPS?
- How can I get WordPress to save comments in markdown format?
- add_query_arg not working
- WooCommerce get_price returning wrong price when used via ajax
- How to ‘clone’ a wp plugin to make small changes
- Open Post Thumbnail in New Child Theme File in WordPress
- add mediaelement.js plugins into WordPress video player control bar
- Shortcode button dosent work for all posts. Work for first post only
- How to stop xmlrpc attacks without disabling component to allow JetPack to work in WordPress?
- How to keep users unique id stored in session in addition to IP in WordPress plugin?
- Where should I save an API key of my user when installing my plugin?
- Prevent a plugin from being automatically activated