My Profile button

Status: 
Solved
Question: 

How can I Only display "My Profile" Button if the user have a profile or when a user click on the "my Profile" button and dont have a profile yet it will open a create profile node? Please help?

Responses

1. I can refer you to the "to

I can refer you to the "to do" block a bit further in the book. Where a similar if statement is used.

2. Can you give me a page

Can you give me a page number, please I cant find it.

3. Got it, For those people out

Got it, For those people out there that might want to do the same, here it is:

Note: Just check the image path, replace [yoursite] with your site domain or defualt.

<?php
global $user;
$myuid= $user->uid;
$node= content_profile_load(profile, $myuid);
//profile above=the name of our content type
$profileid= $node->nid;

if (!empty($node->nid)){
//if yes: display an edit link:
$nodeid = $node->nid;
$profilepath='node/'.$node->nid;
//if not, display a create link:
}else{$profilepath='node/add/profile';}
$myimage=theme_image('sites/[yoursite]/files/images/myprofile.png');
print l($myimage, $profilepath, array('html' => true))
?>

4. It's great that you share

It's great that you share your solution! Thanks!

5. Thats what Drupal is all

Thats what Drupal is all about.