In my project I have a privacy policy form page. After login, though custom code I am redirecting to that page. When user check the privacy policy, I will store the data in variable table.
What I need is if I click any page with out accepting the privacy policy, I need to again redirect to privacy page. I need to check this logic in every page load. Where I need to check this? Is it on hook_init(). When I given this in hook_init(), which is not working. Please see my below code.
$getAcc = variable_get('privacy_38');
if($getAcc == 1) {
global $user;
$accessRedirection = 'privacy/accept';
$afterUserView = 'user/' . $user->uid . '/view';
$options = array('query' => array('destination' => $afterUserView));
drupal_goto($accessRedirection, $options
}
Where I need to put this code. Is it in theme template. If so, in which hook, I need to put this code. Please anybody help me.
That's definitely the place to do it (hook_init), but will take a bit more than what you have to fully achieve what you need. There's a module that implements something very similar to this that you might want to have a look at if you haven't yet: https://www.drupal.org/project/legal
Hope this helps!