wordpress help

I have a wordpress site.
I am trying to detect if a user is logged in.
If they are i want to give them a link that will send them to : URL/username.

If the are not i want to send them to URL/wp-login.php

This is what i have tried so far to no avail.
can some one tell me where i am going wrong?

This one everything works except the link extension. I think it a php with in php thing.
It works out side of the if else statment.

[php]


<?php
if ( is_user_logged_in() ) {
echo ‘My Profile’;
} else {
echo ‘Log In’;
}
?>
[/php]

This one breaks the site:

[php]


<?php
global $userdata;
if ( is_user_logged_in() ) {
echo ‘My Profile’;
} else {
echo ‘Log In’;
}
?>

[/php]

Any help would be great.

Well, not sure what you are trying to do, but, all I see is that you are displaying links to pages.
Is that really what you want to do? To force a user to move to a place in your site, you do not display a link.
Instead, you make them move using this type of PHP function:
header (“Location: SomeFolderOnSite/username/NewWebPage.php”);
This type of command sends them to the page you want them on. If the folder is lower on your site, you might
need to use “…/” to back up one level, etc…

Not sure if this is what you need, but, hope it helps…

You are using the get_currentuserinfo function incorrectly, look here, get_currentuserinfo().

Sponsor our Newsletter | Privacy Policy | Terms of Service