Arrow

Redirect by client IP | Peter's Login Redirect | Forum

Back to the login redirect plugin page
 
Current User: Guest
Search Forums:


 






Minimum search word length is 4 characters – Maximum search word length is 84 characters
Wildcard Usage:
*  matches any number of characters    %  matches exactly one character

Redirect by client IP

Reply to Post Add a New Topic
UserPost

3:46 pm
April 8, 2011


belg4mit

Guest

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!

8:35 am
April 12, 2011


Peter

Admin

posts 732

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
April 12, 2011


belg4mit

Guest

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:

function redirect_to_front_page( $redirect_to, $requested_redirect_to, $user )
{
global $wpdb, $rul_db_addresses;

+ #Kiosk-specific redirect
+ if( preg_match('/^192\.168\.15\./', $_SERVER['REMOTE_ADDR']) )
+ return '/kiosk';

9:05 pm
June 5, 2011


Peter

Admin

posts 732

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):

function redirectByIP( $empty, $redirect_to, $requested_redirect_to, $user )
{
$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 );

8:59 am
June 6, 2011


belg4mit

Guest

Thanks!

Reply to Post

Reply to Topic:
Redirect by client IP

Guest Name (Required):

Guest Email (Required):

HTML Editor
Smileys
Confused Cool Cry Embarassed Frown Kiss Laugh Smile Surprised Wink Yell
Post New Reply

Guest URL (required)

Math Required!
What is the sum of:
12 + 4