0

In my user-profile.tpl.php file In print fields like this :

<?php 


    global $user;
    $user_id = arg(1);

    $user_item = user_load_by_name($user->name);


    if($user->uid == $user_id) {
        echo 'I'm connected';
        print render ($user_profile['field_mon_statut']);
    }

 ?>

I wrote this exact same code in html.tpl.php but it does not appear..

Thanks for your help !

2 Answers 2

0

U are setting $user variable inside if condition, while in if u have condition that $user->uid, so it will compute as false, and it will not go inside if condition.

You will have to write:

global $user;
if($user->uid) {
// Your code

// Edited

global $user;
$user_id = arg(1);

// $user_item = user_load($user->uid);

if($user->uid == $user_id) {
    echo 'I m connected';
    print render ($user_profile['field_mon_statut']);
}
5
  • I did this but still not work Jan 9, 2016 at 15:18
  • Why are u using double if condition.. ?, and what is user_profile, it is not set.I think it is not complete code, can u provide me complete code of the file. Jan 9, 2016 at 16:13
  • I edited my post, you can check it Jan 9, 2016 at 16:31
  • ($user->uid != 0) use this condition in your code
    – user52318
    Jan 11, 2016 at 5:24
  • Please try above edited answer.. Jan 11, 2016 at 6:20
0

I think the problem is in the line where you use echo

<?php 
    global $user;
    $user_id = arg(1);

    $user_item = user_load_by_name($user->name);

    if($user->uid == $user_id) {
        echo "I'm connected";
        print render ($user_profile['field_mon_statut']);
    }

 ?>

Try to use the code above and check.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.