News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Retrieving Custom Profile Field Data

Started by virus52, September 22, 2009, 08:48:41 AM

Previous topic - Next topic

Arantor


amuir

#21
My first round did include the member name, and it wouldn't *hurt* to have it in there, but the IGN will be the primary way we'll be identifying members.

Edit: Thinking about it again, I'd probably prefer to have it in there, even if it's something I end up stripping out later. For now, it lets me confirm that everything is matched up correctly.

amuir

I've just added another Custom Profile Field to the forum which I may want included later on, but I should be able to figure out how to do that once you can help me with this building block. Thanks!

amuir

Arantor seems to have moved on to other things. Can anybody else help me with this?

Arantor

I haven't, I've just been very busy, and formulating the queries for this isn't exactly easy. I've been trying to figure out whether to run with one megaquery to get everything or break it down into separate queries.

And where do you want all this to be, in a page in the forum, or in a separate page based on SSI.php?

amuir

OK, thanks. In a way, I'm glad to hear you say it's not as easy as I thought it would be. Makes me feel at least a *little* less like a noob. :D

This will not be part of the forum code. This is for a separate script which is using SSI.

Thanks again for your continued assistance!

Arantor

And is there any permission control required?

amuir

The script already successfully checks to make sure the user is logged in and a member of the "validated" member group.  Is that what you meant by permission control?

Arantor

Yeah, I didn't know if you had that already or not, or whether you wanted to set up an actual permission to trigger it.

I'll see if I can find some time tonight to work on this some more.

amuir

Nope, I think the only piece I'm missing is how to retrieve the various Custom Profile fields for each user as I loop through the memberlist and stick them into variables.  I'm already looping through the memberlist fine, and building the table, it's just that my cells in the table are all blank (except for the membername).

I'll keep checking back. Thanks!

Arantor

How are you getting the memberlist, exactly?

amuir

Probably not the "best" way to do it, but here's what I have so far and it works (except for the missing Custom Profile fields)...

$SQL = " SELECT * FROM koc_members ";
$SQL .= " WHERE 1 ";

# execute SQL statement
$WotPlist = mysql_query($SQL);

# check for errors
if (!$WotPlist) { echo( mysql_error()); }
else
{
# display results
while ($row = mysql_fetch_array($WotPlist))
{
$WotP_memlisted = $row["id_member"];
$WotP_memnam = $row["member_name"];
loadCustomFields($WotP_memlisted.'forumProfile');
foreach ($context['custom_fields'] as $field)
{
$IGN     = $field['cust_ign'];
$coords1 = $field['cust_coords1'];
$coords2 = $field['cust_coords2'];
$resourc = $field['cust_resourc'];
}

$output = "<TR><TD>" . $WotP_memnam . "</TD><TD>" . $IGN . "</TD><TD>" . $coords1 . "</TD><TD>" . $coords2 . "</TD><TD>" . $resourc . "</TD></TR>";
echo $output;
}

}

Arantor

That gets every user. I thought you wanted it limited to a given membergroup?

amuir

Yes, for now it does, but it's no big deal to add another clause to the WHERE statement (or exclude later with a conditional). Just haven't changed anything since I was waiting to hear back from you on the Custom Profile Fields before I go mucking in it again. :D

Arantor

It's kind of important I know whether you plan to change it though. The most efficient way will depend greatly on it.

amuir

OK, may as well have it only return members who are in the "Validated" membergroup (id=9).

The only other future change I foresee is that I may need to add additional columns to the table (meaning additional Custom Profile Fields) if more data becomes relevant. But there is currently nothing else I know of right now.

Arantor

OK, I think that all makes sense, I'll try and work on that today if I get time - no promises though.

amuir

Merry Christmas and Happy New Year! :)

Just checking in to see how things are going.  Anything else I can do to make it easier?

Arantor

Sorry, just been so busy with other stuff over the last couple of weeks I just haven't had time to sit and poke at this :(

amuir

I know you're busy, but maybe you could just give me a hint on what I'm doing wrong?  I'd like to get moving with this project, even if I have to stumble my way through it.  Since it's external to SMF, it won't matter too much if it's not the most efficient way of doing it, and I could easily clean up the code later.  Thanks!

Advertisement: