Home » Joomla » Joomla Web development » Make Specific Page available for only register user

The answer to this is a simple WordPress if else statement.  The code below is what you need:

<strong><?php if (is_user_logged_in()) { ?></strong>

<span style="color: #999999;">//do whatever you want if the user is logged in here</span>

<strong><?php } else { ?></strong>

<span style="color: #999999;">//do whatever you want if the user is NOT logged in here</span>

<strong><?php } ?></strong>

You can force user to Login to see content of wordpress page content by login

<strong><?php else:</strong>

<strong>wp_die</strong>(‘Sorry, you must first <a href=”/wp-login.php”>log  in</a> to view this page. You can <a  href=”/wp-login.php?action=register”>register free here</a>.’);

<strong>endif; ?></strong>

or

<strong><code><?php </code><code>else</code><code>:</code></strong></div>
<div><code><strong>wp_die</strong>(</code><code>'Sorry,  you must first <a href="/wp-login.php">log in</a> to view  this page. You can <a  href="/wp-login.php?action=register">register free here</a>.'</code><code>);</code></div>
<div><strong><code>endif</code><code>; ?></code></strong>

And you can redirect to specific page after Login by wrting following code

<strong><code><?php </code><code>else</code></strong><code><strong>:</strong> </code><code>echo</code><code>(</code><code>'Sorry,  you must first <a href="/wp-login.php?redirect_to=index.php/YOUR URL  HERE/" rel="nofollow">log in</a> to view this page.'</code><code>)<strong>;</strong> </code><strong><code>endif</code><code>; ?></code></strong>

Reference Links:

WordPress Function_Reference for is_user_logged_in
Require login for wordpress pages specific page

Array ( [0] => Joomla Web development, Just Blogging, Tips-n-Tricks, Web development, Wordpress )