Is there anyway to query a MySQL database and display the query on the individual profile pages of the forum users? I don't think the "Custom Profile Fields" allow for php do they?
Hi, could you please explain this? Perhaps with an example?
Do you want to display the results of a particular query? If so, what query?
Sorry, let me try and explain better. I have a file database. I would like to showcase which files were uploaded by each user (on the main page) on their forum user profiles.
SELECT * FROM uploads WHERE author_id = uid;
while()
{
echo;
}
Of course, I would also need someway to sync the IDs of both main site/forum accounts which I have not thought up yet. Suggestions welcomed! Hope that made it more clear?
You probably want to make a plugin.
It'll probably contain some code like:
$plugins->add_hook('member_profile_end', 'show_my_query');
function show_my_query()
{
global $mybb, $db, $memprofile, $user_uploads;
$query = $db->query('SELECT * FROM uploads WHERE author_id = '.$memprofile['uid']);
$user_uploads = '';
while($file = $db->fetch_array($query))
{
$user_uploads .= htmlspecialchars_uni($file['filename']) . '<br />';
}
}
Then you'd have {$user_uploads} placed somewhere in your member_profile template.
Hope that helped.
Thank you for the help Zinga. It worked perfectly. Could you give any advice on how I would go on to edit the layout? Never played around with Templates before, so don't really know what to do. I tried, to no avail
:
$user_uploads = '<table border=\"0\" cellspacing=\"{$theme['borderwidth']}\" cellpadding=\"{$theme['tablespace']}\" class=\"tborder\"><tr><td class="thead"><b>User Uploads</b></td></tr><tr><td class=\"trow1\">';
while($file = $db->fetch_array($query))
{
$user_uploads .= htmlspecialchars_uni($file['fileName']) . '<br />';
}
$user_uploads .= '</td></tr></table>';
(copied from the signature template
Is there any guide to making mybb plugins?
--------------------
Nevermind, did some searching and found the solution myself. I can just place all the html code directly into member_profile. One last question. What is the variable to display the user's forum name? ie. You use {$formattedname} to show the formatted name. Is there a variable to simply show the an unformatted name?
I came across a plugin that enables you to split the comments & trackbacks into separate lists. This tidies up your comments section & also makes your comments much more enjoyable to read & also reduces excess spam on the page that could have a negative effect on your keyword density.
I think you have the wrong thread.
Anyway, still looking for a variable to use in member_profile which will display the user's username?
I think {$memprofile['username']} should display the username on the profile page, unformatted (haven't checked, but should be right).