<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Paging - Themespress</title>
	<atom:link href="https://themespress.ca/en/sujets/paging/feed/" rel="self" type="application/rss+xml" />
	<link>https://themespress.ca/en/</link>
	<description>Plugins, tutoriels et ressources WordPress</description>
	<lastBuildDate>Sat, 01 Oct 2022 18:35:42 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1</generator>

<image>
	<url>https://themespress.ca/wp-content/uploads/2020/10/cropped-Favicon-Themepress.ca_-32x32.png</url>
	<title>Paging - Themespress</title>
	<link>https://themespress.ca/en/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>WordPress: Redirecting a Private Page to Customer Account Page</title>
		<link>https://themespress.ca/en/wordpress-redirecting-a-private-page-to-customer-account-page/</link>
					<comments>https://themespress.ca/en/wordpress-redirecting-a-private-page-to-customer-account-page/#respond</comments>
		
		<dc:creator><![CDATA[Daniel]]></dc:creator>
		<pubDate>Wed, 11 Apr 2018 21:16:06 +0000</pubDate>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Paging]]></category>
		<category><![CDATA[Users]]></category>
		<guid isPermaLink="false">https://themespress.ca/?p=5052</guid>

					<description><![CDATA[]]></description>
										<content:encoded><![CDATA[<div class="wpb-content-wrapper"><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper">
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>With this tutorial, we will create a function <strong>that will redirect a private page</strong>. By default all private pages are password protected and limited to WordPress users. If non-connected users try to access it, it redirects to a 404.</p>
<p>While we want to keep the same default conditions when we&#8217;re testing our page privately, we want to redirect it to our homepage.</p>
<p>With the new function that we need to add into our <strong>functions.php file</strong>, we need to validate <strong>two conditions</strong>: first if we land on the 404 and then we validate that our query is valid for a private page.</p>

		</div>
	</div>
<h2 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >WordPress: Redirect Private Page to Customer Account Page</h2><div id="ts-enlighterjs-container-6731299" class="ts-enlighterjs-container-single-enabled  " style="width: 100%;  margin-top: 0px; margin-bottom: 0px;" data-enlighter-doubleclick="true" data-enlighter-windowbutton="true" data-enlighter-windowtext="New Window" data-enlighter-rawbutton="true" data-enlighter-rawtext="RAW Code" data-enlighter-infobutton="false" data-enlighter-infotext="EnlighterJS" data-enlighter-indent="2"><pre id="ts-enlighterjs-pre-6731299" class="" style="white-space: pre-wrap; height: 100%; margin: 0; padding: 0;" data-enlighter-language="php" data-enlighter-theme="enlighter" data-enlighter-group="" data-enlighter-title="" data-enlighter-linenumbers="true" data-enlighter-lineoffset="1" data-enlighter-highlight="">////////////////////////////////// Redirect private page  ////////////////////////////////////////

add_action(&#039;template_redirect&#039;, &#039;themespress_private_content_redirect_to_login&#039;, 9);
function themespress_private_content_redirect_to_login() {
  global $wp_query, $wpdb;
  if (is_404()) {
    $private = $wpdb-&gt;get_row($wp_query-&amp;gt;request);
    $location = home_url();
    if( &#039;private&#039; == $private-&gt;post_status  ) {
      wp_safe_redirect($location);
      exit;
    }
  }
}</pre></div>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>As you can see, we are fulfilling the requirements and now we need to create a new variable that we&#8217;ll call <strong>$location</strong> and determine the redirect path. On our example, we used <strong><a href="https://codex.wordpress.org/Function_Reference/home_url" target="_blank" rel="noopener">home_url()</a></strong>.</p>
<p>When we validate that is a private page, we trigger the wp_safe_redirect from the <strong>$location</strong> variable.</p>

		</div>
	</div>
</div></div></div></div>
</div><p>The post <a href="https://themespress.ca/en/wordpress-redirecting-a-private-page-to-customer-account-page/">WordPress: Redirecting a Private Page to Customer Account Page</a> first appeared on <a href="https://themespress.ca/en/">Themespress</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://themespress.ca/en/wordpress-redirecting-a-private-page-to-customer-account-page/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
