Redirect by client IP | Peter's Login Redirect | Forum
Back to the login redirect plugin page
3:46 pm
Would you consider adding the ability to redirect to a certain location if the client IP matches a certain class? If it does not, it would fail over to the other rules? I've patched our local install of an older version to do so, but it would be easier to keep up to date if it were not custom.
We use this because we have dedicated kiosk for staff to access our site when they are in the office, and there is a specific page they are most likely to access, but when off site there are other areas they are more likely to need.
TIA!
Can you share your code? At least in the short term, I don't think I would add such functionality. But your code might help others in the meantime and could also serve as the basis for including the functionality in the core plugin release.
In general, I've considered adding generic hooks within my plugin, although I realized that people would then be creating plugins for my plugin. You could instead use the WordPress hook that I use in your own separate plugin to add functionality before or after WordPress loads my plugin. I could add my own hooks for people to add redirect rules in between my plugin's rules, if there's enough demand for it.
11:14 am
There's not too much to it, since it's hard-coded rather than having user settings, but it's enough to put the module out of sync an a PITA to keep up to date:
{
global $wpdb, $rul_db_addresses;
+ #Kiosk-specific redirect
+ if( preg_match('/^192\.168\.15\./', $_SERVER['REMOTE_ADDR']) )
+ return '/kiosk';
In version 2.1.0 of the plugin you can now add your own extensions to the plugin to accomplish the above. See readme.txt included in the plugin for full documentation. Here is an example of code for your own plugin to add logic before any of the redirect plugin's checks (sorry about the lack of indenting by the forum software):
{
$ip_check = '192.168.0';
if( 0 === strpos( $_SERVER['REMOTE_ADDR'], $ip_check ) )
{
return '/secret_area';
}
else
{
return false;
}
}
add_filter( 'rul_before_user', 'redirectByIP', 10, 4 );