Simple Machines Community Forum

SMF Support => SMF 1.1.x Support => Topic started by: patchwolf on April 14, 2009, 12:15:46 AM

Title: Retrieving membername from SMF session
Post by: patchwolf on April 14, 2009, 12:15:46 AM
Hello,

New to SMF, but I'm a php/mySQL hobbyist developer.  I'm helping out a friend who wants to use SMF as a roleplaying game tool, and wants to create a character table for each user in mySQL that is tied to a user in the forums.

Example:


smf_members
| ID_MEMBER |   memberName | ...
| 1               |  patch           |
| 2               |  Evan            |

character_patch
| OWNER_ID | CharName |
| 1  | Ghost |

character_Evan
| OWNER_ID | CharName |
| 2  | Niobe |


My first question is hopefully relatively simple:  How can I retrieve the memberName of the current session?  I can read the session_id(), but I seem to be running into trouble gathering the memberName, which will be used to create the new table...

Any help you guys can provide would be appreciated.

Patch
Title: Re: Retrieving membername from SMF session
Post by: patchwolf on April 15, 2009, 12:09:04 AM
Bumping... I'm hoping it's been more than 24 hours.
Title: Re: Retrieving membername from SMF session
Post by: Informatics on April 15, 2009, 06:29:14 AM
global $context, $user_info;

echo 'USER ID: ' . $context['user']['id'];
echo '<br />Username: ' . $context['user']['username'];
echo '<br />Display name: ' . $context['user']['name'];
echo '<br /> Email: ' . $context['user']['email'];
echo '<br /> IP Address: ' . $user_info['ip'];
echo '<br /> Posts: ' . $user_info['posts'];
Title: Re: Retrieving membername from SMF session
Post by: H on April 15, 2009, 07:19:34 AM
You'll need to include SMF's SSI.php file, if you want Cyclon Boy's code to work in a page outside of SMF
Title: Re: Retrieving membername from SMF session
Post by: patchwolf on April 15, 2009, 08:45:24 AM
Thank you both so much!!!

Cyclon Boy for the code, and H for the crucial include.  You guys rock.
Title: Re: Retrieving membername from SMF session
Post by: H on April 15, 2009, 12:10:54 PM
Glad that did what you wanted :D