Fatal error: Call to undefined function arg()



I get Fatal error: Call to undefined function arg() in my hook_init() in my custom module when checking for arg(1). This works well for authenticated user, but fails for logged out users. Any help?



Try disabling cache and/or in your custom code check for arg() function as follows:

<?php
  
if (function_exists('arg') && arg(0) == 'node' && (is_numeric(arg(1)) || is_numeric(arg(2)))) {
?>