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 !

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']);
}
| improve this answer | |
  • I did this but still not work – Corentin Branquet Jan 9 '16 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. – Manoj Bisht Jan 9 '16 at 16:13
  • I edited my post, you can check it – Corentin Branquet Jan 9 '16 at 16:31
  • ($user->uid != 0) use this condition in your code – user52318 Jan 11 '16 at 5:24
  • Please try above edited answer.. – Manoj Bisht Jan 11 '16 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.

| improve this answer | |

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.