Agatha Harkness 59 Share Posted October 13, 2020 I was trying out some code to show the last poster's gif from the profile field in the forum index areas. I am using the below mybb plugin: http://mybbhacks.zingaburga.com/showthread.php?tid=260 I am trying to access profile userfields for the user profile of the last poster in a forum. Now. The below gives me the correct name from the last poster, but when i try an fid variable it only shows the logged in user's own last post fields and hides all other lastposter fields. <?php $cuser = get_user($lastpost_data['lastposteruid']); echo $cuser['username']; ?> ^ gives me the correct username of the last poster <?php $cuser = get_user($lastpost_data['lastposteruid']); echo $cuser['fid4']; ?> ^ expected it to give me the profile field 4 of the lastposter. However it gives me the profile field 4 of the logged in user only in the lastposts by the logged in user. Link to comment Share on other sites More sharing options...
Admin Morrigan 1,826 Admin Share Posted October 13, 2020 Try printing the variables to see what you get and paste them in here in a code box. <? print_r($cuser); ?> It will tell us a few things but primarily what your mod is actually pulling. @Lady Croft 1 Profile set made by myself and original Artwork by Fae Merriman, my daughter. Link to comment Share on other sites More sharing options...
Agatha Harkness 59 Author Share Posted October 13, 2020 (edited) url('She-RaArray ( [uid] => 1 [username] => She-Ra [postnum] => 32 [threadnum] => 15 [avatar] => ./uploads/avatars/ablahblah [avatardimensions] => 200|400 [avatartype] => upload [usergroup] => 4 [additionalgroups] => [displaygroup] => 4 [usertitle] => Administrator [regdate] => 1583380159 [lastactive] => 1602600405 [lastvisit] => 1602594609 [lastpost] => 1602081803 [website] => [icq] => 0 [skype] => [google] => [birthday] => [birthdayprivacy] => all [signature] => [allownotices] => 1 [hideemail] => 0 [subscriptionmethod] => 0 [invisible] => 0 [receivepms] => 1 [receivefrombuddy] => 0 [pmnotice] => 1 [pmnotify] => 1 [buddyrequestspm] => 1 [buddyrequestsauto] => 0 [threadmode] => linear [showimages] => 1 [showvideos] => 1 [showsigs] => 1 [showavatars] => 1 [showquickreply] => 1 [showredirect] => 1 [ppp] => 0 [tpp] => 0 [daysprune] => 0 [dateformat] => 0 [timeformat] => 0 [timezone] => 0 [dst] => 0 [dstcorrection] => 0 [buddylist] => [ignorelist] => [style] => 9 [away] => 0 [awaydate] => 0 [returndate] => 0 [awayreason] => [notepad] => [referrer] => 0 [referrals] => 0 [reputation] => 0 [language] => [timeonline] => 231236 [showcodebuttons] => 1 [totalpms] => 3 [unreadpms] => 0 [warningpoints] => 0 [moderateposts] => 0 [moderationtime] => 0 [suspendposting] => 0 [suspensiontime] => 0 [suspendsignature] => 0 [suspendsigtime] => 0 [coppauser] => 0 [classicpostbit] => 0 [loginattempts] => 1 [loginlockoutexpiry] => 0 [usernotes] => [sourceeditor] => 0 [ougc_awards] => [ougc_awards_owner] => 0 [autoresponder] => 0 [autorespondertext] => [autorespondertitle] => [autoresponderbanned] => 0 [myalerts_disabled_alert_types] => Array ( ) [as_uid] => 0 [as_share] => 0 [as_shareuid] => 0 [as_sec] => 0 [as_secreason] => [as_privacy] => 0 [as_buddyshare] => 0 [ufid] => 1 [fid1] => discordaddy [fid2] => 323148102964084736 [fid3] => Undisclosed [fid4] => https://media3.giphy.com/media/JRrsVhXZYx6g4MVbJx/giphy.gif [pms_total] => 3 [pms_unread] => 0 [ismoderator] => 1 [unreadAlerts] => 3 ) ') minus some privacy bits like password etc. cheers. i had tried fid 1 in case the url was buggy. EDIT: I just checked and it doesnt show the fid variables on every user's list. even fellow admin usergroup's users 'testaccountArray ( [uid] => 32 [username] => testaccount [postnum] => 1 [threadnum] => 0 [avatar] => [avatardimensions] => [avatartype] => [usergroup] => 4 [additionalgroups] => [displaygroup] => 0 [usertitle] => [regdate] => 1584301812 [lastactive] => 1602598218 [lastvisit] => 1602598218 [lastpost] => 1602082341 [website] => [icq] => 0 [skype] => [google] => [birthday] => [birthdayprivacy] => all [signature] => [allownotices] => 1 [hideemail] => 0 [subscriptionmethod] => 0 [invisible] => 0 [receivepms] => 1 [receivefrombuddy] => 0 [pmnotice] => 1 [pmnotify] => 0 [buddyrequestspm] => 1 [buddyrequestsauto] => 0 [threadmode] => linear [showimages] => 1 [showvideos] => 1 [showsigs] => 1 [showavatars] => 1 [showquickreply] => 1 [showredirect] => 1 [ppp] => 0 [tpp] => 0 [daysprune] => 0 [dateformat] => 0 [timeformat] => 0 [timezone] => 0 [dst] => 1 [dstcorrection] => 2 [buddylist] => [ignorelist] => [style] => 9 [away] => 0 [awaydate] => 0 [returndate] => 0 [awayreason] => [notepad] => [referrer] => 0 [referrals] => 0 [reputation] => 0 [language] => [timeonline] => 7100 [showcodebuttons] => 1 [totalpms] => 1 [unreadpms] => 0 [warningpoints] => 0 [moderateposts] => 0 [moderationtime] => 0 [suspendposting] => 0 [suspensiontime] => 0 [suspendsignature] => 0 [suspendsigtime] => 0 [coppauser] => 0 [classicpostbit] => 0 [loginattempts] => 1 [loginlockoutexpiry] => 0 [usernotes] => [sourceeditor] => 0 [ougc_awards] => [ougc_awards_owner] => 0 [autoresponder] => 0 [autorespondertext] => [autorespondertitle] => [autoresponderbanned] => 0 [myalerts_disabled_alert_types] => [] [as_uid] => 1 [as_share] => 0 [as_shareuid] => 0 [as_sec] => 0 [as_secreason] => [as_privacy] => 0 [as_buddyshare] => 0 ) '); Edited October 13, 2020 by Lady Croft Link to comment Share on other sites More sharing options...
Admin Morrigan 1,826 Admin Share Posted October 13, 2020 That would be the core issue. But odd that it pulls other info. I’m assuming it’s pulling data from the last loaded last post user, not necessarily the logged in user. Try adding data to that test account. 1 Profile set made by myself and original Artwork by Fae Merriman, my daughter. Link to comment Share on other sites More sharing options...
Agatha Harkness 59 Author Share Posted October 13, 2020 It is odd indeed. I tried three accounts now, tried changing the membergroups. I ticked yes to all custom profile settings, checked the profile fields are visible to all, and had content written in each within the 3 other profiles. So there's info within the profiles. I tried changing the fid4 to username and uid which show up correctly in all 3 test accounts. But the custom fields don't show up in the print_r unless it's the logged in account. If i switch account, the data shows for the logged in and vanished from the others. Could there be a admincp setting i've missed or a plugin file line i need to edit for customprofiles? Link to comment Share on other sites More sharing options...
Admin Morrigan 1,826 Admin Share Posted October 13, 2020 No. I believe the get_data command is only good for the basic data of the user. 1 Profile set made by myself and original Artwork by Fae Merriman, my daughter. Link to comment Share on other sites More sharing options...
Agatha Harkness 59 Author Share Posted October 13, 2020 ah. data command. I adjusted my php section and that seems to have done it. Cheers! Link to comment Share on other sites More sharing options...
Admin Morrigan 1,826 Admin Share Posted October 14, 2020 Please post the one you used for others!!! 💖 Profile set made by myself and original Artwork by Fae Merriman, my daughter. Link to comment Share on other sites More sharing options...
Agatha Harkness 59 Author Share Posted October 14, 2020 I double checked this morning and it all seems fine. So yes, it was that get_data call which was linking it to user logged in and not specific lastpost user. For those wanting to know the fix: <?php // Fetch the profile fields from lastposter user $query = $db->query(" SELECT * FROM ".TABLE_PREFIX."userfields WHERE ufid='".$lastpost_data['lastposteruid']."'"); $profilefields = $db->fetch_array($query); ?> {$profilefields['fid4']} Within the forum bit templates. .Using query to find the list of userfields, then target the specific user's. In which case it's the lastposter in the forum. It gave me the lastposter's userfield #4 value. I've tossed the profilefields fid 4 variable in the template's code where i want it. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now