Jump to content

How to have different header.php based on the user logged in


vraghav

Recommended Posts

Hi

I've a created wordpress membership site using wishlist member plugin. But I want to have different header.php based on different logins.

 

Eg: Users are: Print, Web and Free

 

When Free user logs in - I want header1.php to load

When Print user logs in - I want header2.php to load

When Web user logs in - I want header3.php to load

 

If nobody has logged in the default header.php stays.

 

Please assist on how to do this.

 

Regards,

Raghav.

Hey TRQ,

 

Thanks for the response, please can you elaborate on how to use that. Different levels(Print, Web, Free) - different headers (header1, header2, header3)

 

How to use if() function for the levels? Am working it out for a client. Please assist.

 

Thanks.

For a client? You mean someone is paying you to figure this out?

 

An if statement will allow you to change the execution path within your program. This allows you to make choices based on different data.

 

It's a simple concept:

 

if ($that) {
  // do that
} else {
  // do something else
}

 

Now, all you need to do is figure out what data you need to check in your conditions and what code to execute when your checks pass.

 

  • 3 weeks later...

You are checking the user type from database for logged in users?

 

<?php

if($userType="Free"){

?>

<?php include("header1.php");?>

<?php } elseif($userType="Print") { ?>

<?php include("header2.php");?>

<?php } else { ?>

<?php include("header3.php");?>

<?php } ?>

P5system,

 

If you post replies on a php help forum with code that has an opening and closing php tag on every line, you are going to start receiving replies that point out every short-coming with that code, such as how bad code like that looks, and how hard it is to troubleshoot even basic syntax errors in code written like that.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.