{"id":325,"date":"2010-03-21T00:44:38","date_gmt":"2010-03-21T04:44:38","guid":{"rendered":"http:\/\/www.digitalaccesspass.com\/doc\/?p=325"},"modified":"2014-03-01T22:36:23","modified_gmt":"2014-03-02T06:36:23","slug":"customizing-error-messages-on-protected-pages","status":"publish","type":"post","link":"http:\/\/digitalaccesspass.com\/doc\/customizing-error-messages-on-protected-pages\/","title":{"rendered":"Customizing Error Messages On Protected Pages"},"content":{"rendered":"<p>When an unauthorized visitor tries to access a protected page or post, you can choose from among two things that can happen:<\/p>\n<p><strong>1) Display an &#8220;In-Page Error Message<\/strong>&#8220;: They can be presented with an error message that shows a &#8220;lock&#8221; image. You can show the standard DAP version, or you can customize this message and add your own text.<\/p>\n<p>-OR-<\/p>\n<p><strong>2) Redirect to Error Page<\/strong>: They can be redirected to any other page of your choice (WordPress page or post, or a completely non-WP page)<\/p>\n<h2><strong>1. Display &#8220;In-Page&#8221; Error Message<\/strong><\/h2>\n<p>&#8220;In-Page&#8221; basically means that this message will be shown on the same page that the user is trying to access (to which they do not have access). So basically, the content of the very post or page they&#8217;re trying to access, will be replaced by this &#8220;In-Page&#8221; error message.<\/p>\n<p>The default error messages shown by DAP are as follows.<\/p>\n<p><strong>A) If a visitor is NOT logged in, then they will see&#8230;<\/strong><\/p>\n<p><strong>(Image A)<br \/>\n<\/strong><\/p>\n<p><a href=\"http:\/\/www.digitalaccesspass.com\/doc\/wp-content\/uploads\/2010\/03\/dap-error-notloggedin.png\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-345\" style=\"border: 1px solid black;\" title=\"dap-error-notloggedin\" src=\"http:\/\/www.digitalaccesspass.com\/doc\/wp-content\/uploads\/2010\/03\/dap-error-notloggedin.png\" alt=\"\" width=\"460\" height=\"354\" srcset=\"http:\/\/digitalaccesspass.com\/doc\/wp-content\/uploads\/2010\/03\/dap-error-notloggedin.png 460w, http:\/\/digitalaccesspass.com\/doc\/wp-content\/uploads\/2010\/03\/dap-error-notloggedin-300x230.png 300w\" sizes=\"(max-width: 460px) 100vw, 460px\" \/><\/a><\/p>\n<p><strong>B) If a visitor IS logged in, then they will see&#8230; <\/strong><\/p>\n<p><strong>(Image B)<br \/>\n<\/strong><\/p>\n<p><strong><a href=\"http:\/\/www.digitalaccesspass.com\/doc\/wp-content\/uploads\/2010\/03\/dap-error-loggedin.png\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-327\" style=\"border: 1px solid black;\" title=\"dap-error-loggedin\" src=\"http:\/\/www.digitalaccesspass.com\/doc\/wp-content\/uploads\/2010\/03\/dap-error-loggedin.png\" alt=\"\" width=\"450\" height=\"248\" srcset=\"http:\/\/digitalaccesspass.com\/doc\/wp-content\/uploads\/2010\/03\/dap-error-loggedin.png 450w, http:\/\/digitalaccesspass.com\/doc\/wp-content\/uploads\/2010\/03\/dap-error-loggedin-300x165.png 300w\" sizes=\"(max-width: 450px) 100vw, 450px\" \/><\/a><\/strong><\/p>\n<p>If you see <strong>Image A<\/strong> above, there is a line of text that  says: &#8220;<strong>Click here<\/strong> to get access&#8221;.<\/p>\n<p>And in <strong>Image B<\/strong> above, there is a line of text that says: &#8220;If you are a free member, then <strong>click here<\/strong> to purchase access&#8221;.<\/p>\n<p>In both cases, the text &#8220;click here&#8221; is actually a link. And by default, that link will point to whatever you put in the &#8220;<strong>Sales Page URL<\/strong>&#8221; in your DAP Product (to which the above post\/page is part of). See <strong>Image C<\/strong> below.<\/p>\n<p><strong>(Image C<\/strong>)<\/p>\n<p><a href=\"http:\/\/www.digitalaccesspass.com\/doc\/wp-content\/uploads\/2010\/03\/dap-error-salespageurl.png\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-341\" style=\"border: 1px solid black;\" title=\"dap-error-salespageurl\" src=\"http:\/\/www.digitalaccesspass.com\/doc\/wp-content\/uploads\/2010\/03\/dap-error-salespageurl.png\" alt=\"\" width=\"528\" height=\"302\" srcset=\"http:\/\/digitalaccesspass.com\/doc\/wp-content\/uploads\/2010\/03\/dap-error-salespageurl.png 660w, http:\/\/digitalaccesspass.com\/doc\/wp-content\/uploads\/2010\/03\/dap-error-salespageurl-300x171.png 300w\" sizes=\"(max-width: 528px) 100vw, 528px\" \/><\/a><\/p>\n<h3><strong><\/strong><strong>Displaying Custom Error Message<\/strong><\/h3>\n<p>If you wish to customize the above standard error messages, then here&#8217;s what you need to do:<\/p>\n<ol>\n<li>Go to <strong>\/dap\/inc\/<\/strong> folder. There are two files there:<strong>error-loggedin.php<\/strong> , and<br \/>\n<strong>error-notloggedin.php<\/strong><strong> <\/strong><\/li>\n<li>Make a copy of both files on your computer, and add the text &#8216;<span style=\"color: #ff0000;\"><strong>custom<\/strong><\/span>&#8216; to the front of each of the file names of the newly copied files. So the new files are now called:<strong><span style=\"color: #ff0000;\"> <\/span><\/strong><strong><span style=\"color: #ff0000;\"> <\/span><\/strong><strong><span style=\"color: #ff0000;\"> custom<\/span>error-loggedin.php<\/strong> , and<span style=\"color: #ff0000;\"><strong><br \/>\ncustom<\/strong><\/span><strong>error-notloggedin.php<br \/>\n<\/strong><\/li>\n<li>Open <strong>customerror-loggedin.php<\/strong> and <strong>custom<\/strong><strong>error-notloggedin.php <\/strong>and modify them as you please, change the text, formatting, font size, color, etc.<\/li>\n<li>Upload the new files to the same folder &#8211; <strong>\/dap\/inc\/<\/strong> &#8211; as the original error files.That&#8217;s it. DAP will then ignore the old error files, and start displaying your new &#8220;custom&#8221; error messages.<\/li>\n<\/ol>\n<h2><strong><\/strong><strong>2. Redirect to Error Page<\/strong><\/h2>\n<p>Instead of showing an error page (default or custom, from (1) above) you can also redirect the un-authorized user to a completely new page\/post of your choice.<\/p>\n<p>If you see <strong>Image D<\/strong> below, you will see that on the DAP Products page, there is a field called &#8220;<strong>Error Page URL<\/strong>&#8220;.<\/p>\n<p>By default, this is pointing to <strong>\/dap\/product-error.php<\/strong><\/p>\n<p><strong>(Image D)<br \/>\n<\/strong><\/p>\n<p><strong><a href=\"http:\/\/www.digitalaccesspass.com\/doc\/wp-content\/uploads\/2010\/03\/dap-error-errorpageurl.png\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-342\" style=\"border: 1px solid black;\" title=\"dap-error-errorpageurl\" src=\"http:\/\/www.digitalaccesspass.com\/doc\/wp-content\/uploads\/2010\/03\/dap-error-errorpageurl.png\" alt=\"\" width=\"529\" height=\"303\" srcset=\"http:\/\/digitalaccesspass.com\/doc\/wp-content\/uploads\/2010\/03\/dap-error-errorpageurl.png 661w, http:\/\/digitalaccesspass.com\/doc\/wp-content\/uploads\/2010\/03\/dap-error-errorpageurl-300x172.png 300w\" sizes=\"(max-width: 529px) 100vw, 529px\" \/><\/a><br \/>\n<\/strong><\/p>\n<p>Change this to any link you want. Examples&#8230;<\/p>\n<blockquote><p><strong>http:\/\/YourSite.com\/myerrorpage.html<\/strong> , or<\/p>\n<p><strong>http:\/\/YourSite.com\/myerrorpage\/<\/strong><\/p><\/blockquote>\n<p>Whatever you put in the above field (<strong>Error Page URL<\/strong>) is what page the user will be redirected to, when they access a page that they don&#8217;t have access to (either because they have not logged in, or because they are logged in, but don&#8217;t have access to it <em>yet<\/em>).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When an unauthorized visitor tries to access a protected page or post, you can choose from among two things that can happen: 1) Display an &#8220;In-Page Error Message&#8220;: They can be presented with an error message that shows a &#8220;lock&#8221; image. You can show the standard DAP version, or you can customize this message and [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[12,27,45],"tags":[],"_links":{"self":[{"href":"http:\/\/digitalaccesspass.com\/doc\/wp-json\/wp\/v2\/posts\/325"}],"collection":[{"href":"http:\/\/digitalaccesspass.com\/doc\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/digitalaccesspass.com\/doc\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/digitalaccesspass.com\/doc\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"http:\/\/digitalaccesspass.com\/doc\/wp-json\/wp\/v2\/comments?post=325"}],"version-history":[{"count":18,"href":"http:\/\/digitalaccesspass.com\/doc\/wp-json\/wp\/v2\/posts\/325\/revisions"}],"predecessor-version":[{"id":4331,"href":"http:\/\/digitalaccesspass.com\/doc\/wp-json\/wp\/v2\/posts\/325\/revisions\/4331"}],"wp:attachment":[{"href":"http:\/\/digitalaccesspass.com\/doc\/wp-json\/wp\/v2\/media?parent=325"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/digitalaccesspass.com\/doc\/wp-json\/wp\/v2\/categories?post=325"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/digitalaccesspass.com\/doc\/wp-json\/wp\/v2\/tags?post=325"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}