how to redirect the error message page "Sorry, you are not allowed to access this page." to the Home page?
I think that is a function of the theme, which will return that message under whatever conditions it defined. (Hard to say exactly what file of the theme, since you didn't specify the theme name. But a search for that phrase should find the file.)
If I am correct, then you should (best practice) make a child theme, then copy the theme's PHP file that displays that message into the child theme folder. Then edit the file in the child theme folder to change the part of the code that displays the message to a
wp_redirect() (see https://developer.wordpress.org/reference/functions/wp_redirect/ ) . Make sure you include the
exit command after the