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
- What security concerns should I have when setting FS_METHOD to “direct” in wp-config?
- Uncaught Error: Call to undefined function wp_generate_attachment_metadata() @ wp-cron
- How to eliminate weird 404 errors in wp-admin?
- Is there any record of installed plugins in the database?
- Using require_once in a Plugin?
- Simple form that saves to database
- How to call plugin path in JS?
- Get Current user email as a return string value
- Getting Custom Post Type content from main-site of a Multisite
- Stackoverflow type of badge plugin giving warnings in WordPress 3.5
- Plugin.php: PHP Notice: Undefined offset: 0 in
- How to save Clicks of a download link button while it doesn’t matter if we refresh the page or again login/logout
- How to limit WordPress pages during updates?
- How to keep users unique id stored in session in addition to IP in WordPress plugin?
- Prevent a plugin from being automatically activated
- Saving changes in wp_editor
- Output array into one table cell
- how to change the verification url of pie register plugin of wordpress?
- wordpress plugin is not activating from widget
- WpDataTables – View Image Directory
- Using color picker in plugin, does input attribute order matter?
- WordPress 4.8.1 php getting commented
- Issue running db create table query from static method
- Locked out of admin panel after installing HC Custom WP-Admin URL [closed]
- Is there any pre-existing plugin to track and block IPs with suspicious activity on my site?
- Allowing users to Sign-up > Login > Post articles that need approval
- Use $variable from file1.php in file2.php (different file paths)
- Plugin not working & permalink erorr after upgrade to php 7x on Nginx
- Running multiple security plugins
- How to include a custom field in the woocommerce email?
- All custom widgets are not showing in widget area at the same time
- Adding a simple Javascript file with a plugin
- Wierd site output [closed]
- How to write to a separate PHP file in plugin settings
- How to display results from a data table with an encrypted user id?
- I cannot include a file in my plugin settings page
- How to properly replace the_content with the html in a php file?
- How to Add text value in Automatically in this conditions?
- Checkbox show / hide output result
- force logged in user to stay in the dashboard
- Attempting to list all product categories and the price range of all products within them
- Creating an array from form inputs before it is posted to the options database
- Plugin which unlock free gift when you reach some amount in cart
- Problem with Date translation in WordPress
- How to assign a specific service to a specific provider based on location
- How can I create a secure file download in WordPress?
- 500 Internal server error wp_handle_upload_prefilter
- Ajax call to php function doesn’t work PHP code
- How can I make the search bar in my wordpress site search all of the pages rather than just the blog posts?
- WordPress PHP error getting posts from another wordpress blog
- Nested DIV’s across functions in PHP, do not seem to work
- How to insert image into the Settings Page of a Plugin?
- Paginated Comments “reply” does not work!
- How to limit each front-end user to view just his own uploaded files on Amazon S3?
- I created a custom form in HTML/CSS and now I need it to submit … should I create custom PHP or is there a plugin I can use?
- AJAX doesn’t pass variables to the php function in the plugin
- How to add a handler for a button in plugin?
- Move related products after product summary? [closed]
- Visual Composer Data Source?
- Woocommerce disable checkout on specific day
- How to delete Password Protected posts cookies when a user logged out from the site
- Foreach retun in shortcode
- How to add a static image inbetween the product tiles on main shoppage woocommerce?
- How to register a template in [NEW] WordPress site editor through a plugin
- Can I send a body using wp_remote_get()?
- Call to undefined function create_function() – PHP 8.2