Answers.Body: <p>You can do this by specifying your custom Fatal Error Handler at <code>Administer -&gt; System Settings -&gt; Debugging and Error Handling</code>. </p>
  
  <ul>
  <li><p>Enter the name of the function eg <code>myCustomErrorHandler</code> for <code>Fatal Error Handler</code> input field.</p></li>
  <li><p>Define this function in one of the <a href="https://docs.civicrm.org/dev/en/latest/extensions/civix/" rel="nofollow noreferrer">extension</a> <code>.php</code> file. The param should hold the message of the error and if it matches the permission text msg, you can use redirect function to navigate to the login page. Eg.</p>
  
  <pre><code>function myCustomErrorHandler($params) {
    if ($params['message'] == 'error message') {
      CRM_Utils_System::redirect($urlyouwant);
    }
    return FALSE;
  }
  </code></pre></li>
  <li><p>Note the return statement in this function. <code>FALSE</code> is required to call the default error handler in case your function wasn't able to do the needful.</p></li>
  <li><p><code>return TRUE;</code> will not call the default Error handler in CiviCRM.</p></li>
  </ul>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-04-09T07:20:52.533Z
Answers.LastActivityDate: 2018-04-09T07:26:19.913Z
Answers.LastEditDate: 2018-04-09T07:26:19.913Z
Answers.UserDisplayName: jitendra - fuzion
Answers.Body: <p>In addition to jitendra's answer, check Drupal's CiviCRM permissions. Look for "CiviContribute: make online contributions" and make sure all roles, such as anonymous, are checked.. </p>
  
  <p><a href="https://i.sstatic.net/A7Lju.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/A7Lju.png" alt="enter image description here"></a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-04-18T20:46:22.413Z
Answers.LastActivityDate: 2018-04-18T20:46:22.413Z
Answers.UserDisplayName: Christia
Body: <p>I have enabled and configured access for Contribution financial type. When an anonymous user open the a contribute page, it returns the error.</p>
  
  <p><a href="https://i.sstatic.net/cMZlV.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/cMZlV.png" alt="Error Page"></a> </p>
  
  <p>I need to redirect to login page in this case. I don't want to show error page to the user. </p>
  
  <p>Please Help!</p>
  
Tags: <civicontribute><drupal><permissions>
Title: Need to redirect when permission issue happened on CiviCRM Page
ThreadText: # Need to redirect when permission issue happened on CiviCRM Page
  
  (Asked by: username_0 on 2018-04-09)
  
  I have enabled and configured access for Contribution financial type. When an anonymous user open the a contribute page, it returns the error.
  
  [![Error Page](https://i.sstatic.net/cMZlV.png)](https://i.sstatic.net/cMZlV.png)
  
  I need to redirect to login page in this case. I don't want to show error page to the user.
  
  Please Help!
  
  **Tags:** civicontribute, drupal, permissions
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2018-04-09. Score: 3
  
  You can do this by specifying your custom Fatal Error Handler at `Administer -> System Settings -> Debugging and Error Handling`.
  
  * Enter the name of the function eg `myCustomErrorHandler` for `Fatal Error Handler` input field.
  * Define this function in one of the [extension](https://docs.civicrm.org/dev/en/latest/extensions/civix/) `.php` file. The param should hold the message of the error and if it matches the permission text msg, you can use redirect function to navigate to the login page. Eg.
  
    ```
    function myCustomErrorHandler($params) {
      if ($params['message'] == 'error message') {
        CRM_Utils_System::redirect($urlyouwant);
      }
      return FALSE;
    }
  
    ```
  * Note the return statement in this function. `FALSE` is required to call the default error handler in case your function wasn't able to do the needful.
  * `return TRUE;` will not call the default Error handler in CiviCRM.
  
  
  ---
  
  ### Answer by username_2 on 2018-04-18. Score: 0
  
  In addition to username_1's answer, check Drupal's CiviCRM permissions. Look for "CiviContribute: make online contributions" and make sure all roles, such as anonymous, are checked..
  
  [![enter image description here](https://i.sstatic.net/A7Lju.png)](https://i.sstatic.net/A7Lju.png)
  
  
  ---
  
  