0

I need to add my own webpages to a wordpress theme that are totally independent of the theme. I have seen how to do something like this here using adam's answer

How to add a PHP page to WordPress?

However how would i go about making certain pages require a login? If the user is logged it it says "hi joe, go to your area" and if you arent logged in it says "login here"

The login area can look like a separate section and just be independent php pages. However in the existing pages where would I check login status? I would store this in a session variable probably

I assume this type of thing would be theme dependent but I'm just investigating if it is possible. I am guessing I would have to modify the header file to show a specific message based on session variables.

If anyone has an idea for a better approach or a plugin that does this that would be mucch appreciated

Thanks as ever for your help

Community
  • 1
  • 1
user2274191
  • 843
  • 2
  • 14
  • 24

2 Answers2

1

Try at your custom page-

 <?php if ( is_user_logged_in() ) { ... } ?> 
Jitendra Yadav
  • 896
  • 1
  • 6
  • 14
0

as suggested by jitendra you can use wordpress function is_user_loggeed_in to check if user is logged in or not. http://codex.wordpress.org/Function_Reference/is_user_logged_in

and you can use wp_login_form to show login form http://codex.wordpress.org/Function_Reference/wp_login_form

so

 <?php
 if ( is_user_logged_in() ) {
      // your content here  
 } else {
       wp_login_form(); 
 }
 ?>
Bhavesh
  • 355
  • 2
  • 12