By hal9000_jr on
I want to let users submit pictures for thier profile, but choose whether to display them on stories.
I created a custom profile as a checkbox called profile_useImage. When selected, this is 1, when not selected, it's 0. The database is updated OK (I checked).
So I tried to change the node.tpl.php file for the theme. I changed the snippet
if($picture) {
print $picture;
}to
if ($picture && $user->profile_useImage) {
print $picture;
}Thinking that would toggle OK. The image does disappear, but that's probbaly because of an error. :) I can't make appear when I want.
Anyideas? Or is there a better way to do this?
thanks
Comments
I think you need to call profile_load_profile()
Since it sounds like you want to allow the user to chose if their picture is show that seems like a reasonable solution (even simplier let them .choose to upload (or not) their image). The part that missing is that profile fields are not loaded as part of the user object by default so you need to call profile_load_profile(). Your snippet would them become
re: I think you need to call profile_load_profile()
Thanks brother. That got it going.
Profile_load_profile
this is exactly what i'm trying to do, but it does not work for me..
i have created the profile_useImage field, and updated the .tpl.php file, but the image does not load. if i repalce it with just $picture it loads fine..
what am i missing here?
(4.7.4)
Did you update your profile/account?
Did you update your profile/account? so the new field (useImage) has been selected/checked?
Profile_load_profile
hehe.. YESSS..
Not sure if it makes a difference or not, but i'm using FlatForum.. so i'm putting the code in node-forum.tpl.php .. like i said $Picture works fine, as well as a few other modifications i've added..
Got it..
changed $User to $curr_user and it's working..
I think i might be getting the hang of this PHP thing..