I have enabled and configured access for Contribution financial type. When an anonymous user open the a contribute page, it returns the error.
I need to redirect to login page in this case. I don't want to show error page to the user.
Please Help!
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.
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..