This needs to be done within Drupal as my architecture does not allow for htaccess restriction.
I’m coming over from wordpress here so I’ve sort’ve Frankensteined this together from my wordpress code. Any thoughts or help on why this wouldn’t be working?
Or maybe there is a much better way of doing this in code somewhere else? Or with some other function?
I’m on drupal 7.
function hook_init() { if (path_is_admin(current_path())) { // Whitelist $ whitelist = array( 'SOME IP ADDRESS', ); // Check if current user IP is out of the whitelist, then redirect to home if(!in_array($ _SERVER['REMOTE_ADDR'], $ whitelist)) { drupal_goto('frontpage', 302); drupal_exit(); } } }