3

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

I need to redirect to login page in this case. I don't want to show error page to the user.

Please Help!

2 Answers 2

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 .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.

0

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..

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.