Prevent Direct Access (PDA) Gold allows you to grant your protected files access to some specific users or user roles only. Unauthorized people will see your website 404 page or a customized “No Access” Page.
In many cases, you would like users to log in in order to access these files. Once they log in, you want to redirect them back to your protected file URL. You can achieve all of that with 2 simple steps below:
Step 1: Protect your private file with PDA Gold and select “Logged-in users” as file access permission.
Step 2: Put this custom code snippet on your function.php file.
After users log in to your website, they will be redirected to your homepage by default. If you want to redirect them to the protected files that they have just tried to access, put the custom code snippet below at the bottom of your (child) theme’s function.php file:
Note: The first filter and function will override our “No Access Page” settings option. In case you want to redirect users to a custom login page, you should modify line 14 accordingly.
You may want to refer to our blog post to understand more about how to redirect users back to your protected files after login.