Redirect anonym user after click on link i have preprocess function 

function THEME_preprocess_views_view(&amp;$vars) {
    global $user;
    $view = $vars['view'];

    if ($view-&gt;name == 'questions_by_category' &amp;&amp; $view-&gt;current_display == 'page') {
        $vars['header'] = '&lt;div&gt;' . l('Ask your question', 'node/add/question') . '&lt;/div&gt;';
        if($user-&gt;uid == 0) {
            //this code not working
            if($_GET['q'] == 'node/add/question') {
                $path = drupal_get_path();
                drupal_goto('user/login', $path);
            }
        }
    }


i need to redirect anonym user to login page when he click on the link node/add/question, i also tried with arg(0) == 'node' &amp;&amp; arg(1) == 'add' &amp;&amp; arg(2) == 'question' but this wont work. 

The code inside if($user-&gt;uid == 0) { } works fine, i can redirect, but i need to redirect on click only. Also i need to redirect user back on the page after login, and this code :

$path = drupal_get_path();
drupal_goto('user/login', $path); 


seems not working too.
ok i found solution, i just changed link for anonym user

if ($view-&gt;name == 'questions_by_category' &amp;&amp; $view-&gt;current_display == 'page') {
        if ($user-&gt;uid) {
            $vars['header'] = '&lt;div&gt;' . l('Ask your question', 'node/add/question') . '&lt;/div&gt;';
        }
        if ($user-&gt;uid == 0) {
            $vars['header'] = '&lt;div&gt;' . l('Ask your question', 'user/login') . '&lt;/div&gt;';
        }
    }