Guest User

Untitled

a guest
Jan 17th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. add_action ('wp_loaded', 'my_redirect_function');
  2.  
  3. function my_redirect_function() {
  4.  
  5. $ip = '';
  6.  
  7. if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet
  8. {
  9. $ip=$_SERVER['HTTP_CLIENT_IP'];
  10. }
  11. elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy
  12. {
  13. $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
  14. }
  15. else
  16. {
  17. $ip=$_SERVER['REMOTE_ADDR'];
  18. }
  19.  
  20. $country = file_get_contents('http://geoip.maxmind.com/a?l=6QT6fNSdtMVw&i='.$ip);
  21.  
  22. if( $country == 'IE' ) {
  23.  
  24. wp_redirect( get_bloginfo('url') . "/ie/" );
  25.  
  26. exit;
  27.  
  28. }
  29.  
  30. }
  31.  
  32. if( $country == 'IE' ) {
  33.  
  34. if( $country == 'IE' && substr( $_SERVER['REQUEST_URI'], 0, 4 ) == '/ie/' ) {
Add Comment
Please, Sign In to add comment