We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4120
    • 21 Posts
    I am new to creating snippets that work with MODx Revolution, and I am wanting to create on that is turning out to be a problem. I am wanting to create a snippet which redirects anonymous users or users not yet signed in, and users lacking privileges to another page. This snippet would be at the top of all pages and redirect anonymous or users not signed in to a sign in page, and users lacking privileges to a "Not Authorized" page. Here is the code I have so far, and from what I can tell it is not working at all. Any help or advice would be appreciated.

    $autho = $modx->user->isAuthenticated($modx->context->get(’key’));
    $id = empty($id)? $id: 79;

    if(empty($_POST) && $autho){
    $ch = curl_init();
    curl_setopt($ch,CURLOPT_AUTOREFERER,$modx->getOption(’core_path’)."index/php?id=".$id);
    curl_exec($ch);
    curl_close($ch);
    }