Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Recommended Posts

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 post
Share on other sites
  • Admin

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

  • Like 1

adtest3.png

engineeringad.jpg

0_mainsignature.jpg

tapestries_fixed.gif

Profile set made by @jordan of Dark Motives

 

 

Link to post
Share on other sites
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 by Lady Croft
Link to post
Share on other sites
  • Admin

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.

  • Like 1

adtest3.png

engineeringad.jpg

0_mainsignature.jpg

tapestries_fixed.gif

Profile set made by @jordan of Dark Motives

 

 

Link to post
Share on other sites

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 post
Share on other sites

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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    No registered users viewing this page.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use, Guidelines and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.