Hello im new to here and i recently installed sfm, and im trying to work out how i can pull the member info like name amount of posts ect. Can someone help me please?
Thanks
$user_info // ssi.php functions
elaborate more on what youa re doing and include your smf version.
Sorry, Im running 1.1.13 i've already intergrated <?php ssi_recentPosts($num_recent = 4); ?>
and also <?php
if ($context['user']['is_guest'])
{
ssi_login();
}
else
{
ssi_welcome();
ssi_logout();
}
?>
to my website, what i'm trying to do is make a member.php page, where if you are logged in, it will bring up all the user's info.
Thanks
How would that be different from ?action=profile or ?action=profile;u=id?
My php understanding is pretty basic, well where ssi_welcome();
is there some what way of making it give me more info on that user? And maybe where to find a good php book so i can start learning more lol
Here is a photo (http://www.galaticnetwork.co.uk/images/script.png)
Pretty much what i want to do is get all that info and put it on my website without the theme just the info.
Thanks
You can definitely accomplish that with PHP, but you'll need to know some...I'd check out two functions. loadMemberData and loadMemberContext. If I understand what you're trying to do, correctly, they would be very valuable functions to you.
For learning PHP, have you checked out the PHP Manual and w3schools?
Quote from: Labradoodle-360 on March 03, 2011, 04:52:34 PM
I'd check out two functions. loadMemberData and loadMemberContext.
I've read about those functions i just need to learn to insert it so the theme doesn't appear on the page. No i havn't i will give them a google. Thanks
W3Schools - Learn PHP (http://w3schools.com/php/default.asp)
PHP Manual (http://php.net/)
Thank you i will check it out :)
Not a problem, if you have any questions, feel free to ask...
You can even use just SMF's SSI functions to accomplish this.
ssi_welcome() - can return the $context['user'] array.
ssi_queryMembers() - will simply fetch member data which is exactly the same method as Labradoodle-360 posted above however its done for you. You can use ssi_fetchMember() to fetch a specific/group of member ids to retrieve data for without having to specify the queries yourself.
Thanks for sharing that stuff. I'm really no expert on what is in SSI.php, although I probably should learn what's inside it sometime.
Quote from: Project Evolution on March 03, 2011, 05:12:58 PM
You can even use just SMF's SSI functions to accomplish this.
ssi_welcome() - can return the $context['user'] array.
ssi_queryMembers() - will simply fetch member data which is exactly the same method as Labradoodle-360 posted above however its done for you. You can use ssi_fetchMember() to fetch a specific/group of member ids to retrieve data for without having to specify the queries yourself.
Quote from: Labradoodle-360 on March 03, 2011, 05:14:13 PM
Thanks for sharing that stuff. I'm really no expert on what is in SSI.php, although I probably should learn what's inside it sometime.
No prob. ;)
I think the primary reason I've never learned it is because I have not one forum I run. I am just at SMF to help out with support, have fun, and develop mods for people.
Quote from: Project Evolution on March 03, 2011, 05:14:58 PM
Quote from: Labradoodle-360 on March 03, 2011, 05:14:13 PM
Thanks for sharing that stuff. I'm really no expert on what is in SSI.php, although I probably should learn what's inside it sometime.
No prob. ;)
Quote from: Project Evolution on March 03, 2011, 05:12:58 PM
You can even use just SMF's SSI functions to accomplish this.
ssi_welcome() - can return the $context['user'] array.
ssi_queryMembers() - will simply fetch member data which is exactly the same method as Labradoodle-360 posted above however its done for you. You can use ssi_fetchMember() to fetch a specific/group of member ids to retrieve data for without having to specify the queries yourself.
Ahhh thanks alot i will intergrate that and give it a go. :D
Let us know how it goes :)
Um. Just loading SSI.php will load $context['user'], not that there's a great deal in it. ssi_welcome() literally just displays a welcome message, nothing more.
What you actually want to do is, after SSI.php is loaded:
global $context, $memberContext;
if ($context['user']['is_logged'])
{
$return = loadMemberData($context['user']['id'], false, 'profile');
if (!empty($return))
loadMemberContext($context['user']['id']);
}
Then look to see if $memberContext[$context['user']['id']] exists and if it does, you have all the information you could want on your user.
Quote from: Arantor on March 03, 2011, 05:24:03 PM
Um. Just loading SSI.php will load $context['user'], not that there's a great deal in it. ssi_welcome() literally just displays a welcome message, nothing more.
What you actually want to do is, after SSI.php is loaded:
global $context, $memberContext;
if ($context['user']['is_logged'])
{
$return = loadMemberData($context['user']['id'], false, 'profile');
if (!empty($return))
loadMemberContext($context['user']['id']);
}
Then look to see if $memberContext[$context['user']['id']] exists and if it does, you have all the information you could want on your user.
Whats wrong with just loading member data with the other functions I listed..?
Ok this is what i've done so far on a file called Test.php <?php
require_once('forum/SSI.php');
$_SESSION['login_url'] = 'http://galaticnetwork.co.uk' . $_SERVER['PHP_SELF'];
$_SESSION['logout_url'] = 'http://galaticnetwork.co.uk' . $_SERVER['PHP_SELF'];
global $context, $memberContext;
if ($context['user']['is_logged'])
{
$return = loadMemberData($context['user']['id'], false, 'profile');
if (!empty($return))
loadMemberContext($context['user']['id']);
}
?>
Im stuck at this bit, <?php
if ($context['user']['is_guest'])
{
ssi_login();
}
else
{
ssi_welcome();
ssi_logout();
}
?>
do i need to add $memberContext[$context['user']['id']] Or ssi_fetchMember() sorry for being a noob
QuoteWhats wrong with just loading member data with the other functions I listed..?
Well, you could construct the parameters necessary, only for ssi_queryMembers to do some stuff around deciding whether the member is a valid member or not, only for it to call loadMemberData and loadMemberContext, when you could save all the time and hassle because you know it's a genuine member (since they're logged in) and get it directly.
Quotedo i need to add $memberContext[$context['user']['id']] Or ssi_fetchMember() sorry for being a noob
Neither of those will magically just print out all the information you want, but both of them in their own way *get* the data. Since I don't know the HTML you plan to use to print it out, I can't help you with the display part - but if you use the code I posted, $memberContext[$context['user']['id']] has loads of stuff in it you can use to display. You tell me what it is you want to display and how it should look (ideally with the HTML code you wanted to use) and I'll put the PHP around it to make it work.
The html code is <table border="0"
cellpadding="0" cellspacing="0" width="620" height="97">
<tr>
<td width="97" height="97" valign="top"><p align="center"><br>
<img src="images/Pixel3_Avatar.jpg" width="50" height="50"
alt="Pixel3_Avatar.jpg (19028 bytes)"><br>
04/03/11<br>
12:11PM EST</td>
<td width="523" height="97" valign="top"><table border="0" cellpadding="6" cellspacing="0"
width="100%" height="99">
<tr>
<td height="99" valign="top"><p>Member Details:
This is where i want the info to be displayed...
</p>
<p> </p></td>
</tr>
</table>
</td>
</tr>
</table>
I want it to show all the info in the picture below i will cross out the unwanted info. (http://galaticnetwork.co.uk/Code.png) Thanks
You've just given a blank space inside table to dump the content into. If that's truly what you want, fine, but it'll be a mess.
Sorry i coppied the table code out of dreamweaver, I can always adjust the html in dreamweaver. Thanks
Except that I'm putting in PHP in the middle of HTML, which can't so easily be modified...
Quote from: Arantor on March 03, 2011, 06:38:34 PM
Except that I'm putting in PHP in the middle of HTML, which can't so easily be modified...
Haha true sorry im not exactly helpful am i. If it's easier for you, you can put it in a html script easy for you and i'll check it out when i wake up as it's late now. Thank you for helping me i will check the code when im up
Thankss
But it's still going to be PHP, strictly speaking it's going to be PHP producing HTML, and a single apostrophe out of place will break it. That's why I wanted the full code you wanted to use, like a mock-up, before writing a single line of code for it.
Ok heres the full script of the html im useing. I've named it test.php but if it works will name it member.php. <?php
require_once('forum/SSI.php');
$_SESSION['login_url'] = 'http://galaticnetwork.co.uk' . $_SERVER['PHP_SELF'];
$_SESSION['logout_url'] = 'http://galaticnetwork.co.uk' . $_SERVER['PHP_SELF'];
global $context, $memberContext;
if ($context['user']['is_logged'])
{
$return = loadMemberData($context['user']['id'], false, 'profile');
if (!empty($return))
loadMemberContext($context['user']['id']);
}
?>
<html>
<head>
<title>GalaticNetwork</title>
<link rel="stylesheet" href="style.css" type="text/css">
<script language="JavaScript1.2">
function high(which2){
theobject=which2
highlighting=setInterval("highlightit(theobject)",50)
}
function low(which2){
clearInterval(highlighting)
if (which2.style.MozOpacity)
which2.style.MozOpacity=0.3
else if (which2.filters)
which2.filters.alpha.opacity=30
}
function highlightit(cur2){
if (cur2.style.MozOpacity<1)
cur2.style.MozOpacity=parseFloat(cur2.style.MozOpacity)+0.1
else if (cur2.filters&&cur2.filters.alpha.opacity<100)
cur2.filters.alpha.opacity+=10
else if (window.highlighting)
clearInterval(highlighting)
}
</script>
</head>
<body background="images/bg3.jpg">
<div align="center">
<table border="0" cellpadding="0" cellspacing="0" height="92" width="657">
<tr>
<td height="1" width="802" colspan="2"><img src="images/top_bar.jpg" width="800"
height="27"></td>
</tr>
<tr>
<td width="802" height="1" colspan="2"><img src="images/GalacticFederationBanner.png" width="800"
height="110"></td>
</tr>
<tr>
<td width="401" height="1" background="images/nav_bg.jpg"><img src="images/nav_left.jpg"
width="76" height="23" alt="nav_left.jpg (14891 bytes)"></td>
<td width="401" height="1" background="images/nav_bg.jpg"><p align="right"><a href="index.php"><img
src="images/button_home.jpg" width="34" height="23"></a><img
src="images/button_spacer.jpg" width="2" height="23"><a href="about.php"><img
src="images/button_roster.jpg" width="48" height="23"></a><img
src="images/button_spacer.jpg" width="2" height="23"><a href="/forum"><img
src="images/button_forums.jpg" width="50" height="23"></a><img src="images/spacer1.jpg"
width="1" height="23"><img src="images/nav_right.jpg" width="76" height="23"></td>
</tr>
<tr>
<td background="images/bg2.jpg" height="428" width="802" valign="top" colspan="2"><table
border="0" cellpadding="4" cellspacing="0" width="800" height="132">
<tr>
<td height="124" valign="top"><table border="0" cellpadding="0" cellspacing="0"
width="779" height="429">
<tr>
<td height="3" width="788"><img src="images/content_top.jpg" width="791" height="16"></td>
</tr>
<tr>
<td height="426" valign="top" width="788"><table border="0" cellpadding="0"
cellspacing="0" width="782">
<tr>
<td width="162" valign="top"><table border="0" cellpadding="0" cellspacing="0"
height="147">
<tr>
<td height="11" valign="top" background="images/side_bg.jpg"><img
src="images/bar_main.jpg" width="162" height="14"></td>
</tr>
<tr>
<td height="10" valign="top" background="images/side_bg.jpg"> _<a href="index.php">Home</a><br>
_<a href="trailers.php">Trailers</a><br>
_<a href="/downloads">Downloads</a><br>
_<a href="/media">Media</a><br>
_<a href="/member">Members</a><br>
_<a href="/forum">Forums</a><br>
_<a href="about.php">About</a></td>
</tr>
<tr>
<td height="3" valign="top" background="images/side_bg.jpg"><img
src="images/bar_serverstats.jpg" width="162" height="14"></td>
</tr>
<tr>
<td height="2" valign="top" background="images/side_bg.jpg"> <?php ssi_boardStats(); ?></td>
</tr>
<tr>
<td height="4" valign="top" background="images/side_bg.jpg"><img
src="images/bar_newmembers.jpg" width="162" height="14"></td>
</tr>
<tr>
<td height="5" valign="top" background="images/side_bg.jpg">
<?php
if ($context['user']['is_guest'])
{
ssi_login();
}
else
{
ssi_welcome();
ssi_logout();
}
?></td>
</tr>
<tr>
<td height="5" valign="top" background="images/side_bg.jpg"><img
src="images/bar_affiliates.jpg" width="162" height="14"></td>
</tr>
<tr>
<td height="5" valign="top" background="images/side_bg.jpg"></td>
</tr>
<tr>
<td height="45" valign="top" background="images/side_bg.jpg"><p align="left"> Comming soon...<br>
<br>
</td>
</tr>
<tr>
<td bgcolor="#000000" height="1"></td>
</tr>
</table>
</td>
<td width="620" valign="top"><table border="0" cellpadding="0" cellspacing="0">
<tr>
<td> </td>
<td><table border="0" cellpadding="0" cellspacing="0" height="266">
<tr>
<td height="1" valign="top" background="images/content_bg.jpg"><img
src="images/bar_news.jpg" width="620" height="14"></td>
</tr>
<tr>
<td height="132" valign="top" background="images/content_bg.jpg"><table border="0"
cellpadding="0" cellspacing="0" width="620" height="97">
<tr>
<td width="97" height="97" valign="top"><p align="center">INFO TO GO HERE!!!!!</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="1" valign="top" bgcolor="#000000"></td>
</tr>
<tr>
<td height="2" valign="top"></td>
</tr>
<tr>
<td height="0" valign="top" background="images/content_bg.jpg"><img
src="images/bar_news.jpg" width="620" height="14"></td>
</tr>
<tr>
<td height="160" valign="top" background="images/content_bg.jpg"><table border="0"
cellpadding="0" cellspacing="0" width="620">
<tr>
<td width="97" valign="top"><p align="center"><br>
<img src="images/Pixel3_Avatar.jpg" width="50" height="50"
alt="Pixel3_Avatar.jpg (19028 bytes)"><br>
04/03/11<br>
12:09PM EST</td>
<td width="523" valign="top"><table border="0" cellpadding="6" cellspacing="0" width="100%"
height="148">
<tr>
<td height="136" valign="top"><p>Welcome to GalaticNetwork here you will find, the latest Trailers for Movies,Games and Music so have a browse sign up to the forums, and start posting about all the new films comming out, or any other subject.</p>
<p> </p></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="1" bgcolor="#000000"></td>
</tr>
<tr>
<td height="16"></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="802" height="1" colspan="2" bgcolor="#000000"></td>
</tr>
<tr>
<td width="802" height="0" colspan="2"></td>
</tr>
</table>
<p>Copyright<strong> GalaticNetwork 2011, </strong><strong>Template by <a href="http://www.clantemplates.com">ClanTemplates</a></strong></p>
<p> </p>
</div>
</body>
</html>
or if you like i can send you the test.php Thanks
That still doesn't answer what it is I wanted to know.
What I would like you to do is provide a mock-up of the HTML that should be used. You've set aside some space for the profile information but I don't know if it should be a paragraph or a long list or a two column table like the profile page is, or how that should be set up. So if you make a mock up of how the information should look with some dummy values, I can then modify it to put the PHP inside it.
Quote from: Arantor on March 04, 2011, 10:14:16 AM
That still doesn't answer what it is I wanted to know.
What I would like you to do is provide a mock-up of the HTML that should be used. You've set aside some space for the profile information but I don't know if it should be a paragraph or a long list or a two column table like the profile page is, or how that should be set up. So if you make a mock up of how the information should look with some dummy values, I can then modify it to put the PHP inside it.
Ohhh i understand now sure thing i will make the mock now and post code once done. Thanks
Hopefully i have it correct now.
Heres the script <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<table width="200" border="1">
<tr>
<td>Member Info:</td>
</tr>
</table>
<table width="200" border="1">
<tr>
<td>Name</td>
<td>Output here</td>
</tr>
<tr>
<td>Posts</td>
<td>Output here</td>
</tr>
<tr>
<td>Postion</td>
<td>Output here</td>
</tr>
<tr>
<td>Last Active</td>
<td>Output here</td>
</tr>
</table>
<table width="200" border="1">
<tr>
<td height="26">Contact Info:</td>
</tr>
</table>
<table width="200" border="1">
<tr>
<td>Msn</td>
<td>Output here</td>
</tr>
<tr>
<td>Email</td>
<td>Output here</td>
</tr>
<tr>
<td>Status</td>
<td>Output here</td>
</tr>
</table>
<table width="200" border="1">
<tr>
<td>Extra Info</td>
</tr>
</table>
<table width="200" border="1">
<tr>
<td>Gender</td>
<td>Output here</td>
</tr>
<tr>
<td>Age</td>
<td>Output here</td>
</tr>
<tr>
<td>Location</td>
<td>Output here</td>
</tr>
</table>
</body>
</html>
Let me know if it's wrong again lol
Thanks :D
<?php
require_once('forum/SSI.php');
$_SESSION['login_url'] = 'http://galaticnetwork.co.uk' . $_SERVER['PHP_SELF'];
$_SESSION['logout_url'] = 'http://galaticnetwork.co.uk' . $_SERVER['PHP_SELF'];
global $context, $memberContext;
if ($context['user']['is_logged'])
{
$return = loadMemberData($context['user']['id'], false, 'profile');
if (!empty($return))
{
loadMemberContext($context['user']['id']);
$member = &$memberContext[$context['user']['id']];
}
}
else
{
is_not_guest();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<table width="200" border="1">
<tr>
<td>Member Info:</td>
</tr>
</table>
<table width="200" border="1">
<tr>
<td>Name</td>
<td><?php echo $member['realName']; ?></td>
</tr>
<tr>
<td>Posts</td>
<td><?php echo $member['posts']; ?></td>
</tr>
<?php
if (!empty($member['group']))
echo ' <tr>
<td>Position</td>
<td>', $member['realName'], '</td>
</tr>';
?>
<tr>
<td>Last Active</td>
<td><?php echo $member['last_login']; ?></td>
</tr>
</table>
<table width="200" border="1">
<tr>
<td height="26">Contact Info:</td>
</tr>
</table>
<table width="200" border="1">
<?php
if (!empty($member['MSN']['href']))
echo ' <tr>
<td>MSN</td>
<td>', $member['MSN']['link_text'], '</td>
</tr>';
if (!empty($member['email_public']))
echo ' <tr>
<td>Email</td>
<td><a href="mailto:', $member['email'], '">', $member['email'], '</a></td>
</tr>';
?>
<tr>
<td>Status</td>
<td><img src="<?php echo $member['online']['image_href']; ?>" /> <?php echo $member['online']['label']; ?></td>
</tr>
</table>
<table width="200" border="1">
<tr>
<td>Extra Info</td>
</tr>
</table>
<table width="200" border="1">
<?php
if (!empty($member['gender']['image']))
echo ' <tr>
<td>Gender</td>
<td>', $member['gender']['image'], ' ', $member['gender']['name'], '</td>
</tr>';
if (!empty($member['birth_date']) && $member['birth_date'] != '0000-00-00' && $member['birth_date'] != '0001-01-01')
{
list ($birth_year, $birth_month, $birth_day) = sscanf($member['birth_date'], '%d-%d-%d');
$datearray = getdate(forum_time());
echo ' <tr>
<td>Age</td>
<td>', $birth_year <= 4 ? $txt[470] : $datearray['year'] - $birth_year - (($datearray['mon'] > $birth_month || ($datearray['mon'] == $birth_month && $datearray['mday'] >= $birth_day)) ? 0 : 1), '</td>
</tr>';
}
if (!empty($member['location']))
echo ' <tr>
<td>Location</td>
<td>', $member['location'], '</td>
</tr>';
?>
</body>
</html>
Thanks it worked, but there are a few issues
Postion doesn't show and neither does real name.
So i changed the Real Name to show Username
But not sure why Postion isn't working just shows blank
Thanks
Let me guess, you're using 2.0 now? There were a few changes to the underlying code between 1.1 and 2.0...
As for position, I screwed up as you can see it uses $member['realName'] when it should be $member['group'] if I remember rightly.
No still running 1.1.13 i have 2.0 setup but its in a private place for testing.
I will update the code and see if it works
Thanks
Yup that seemed to fix the Postion problem. Everything is working how i wanted it
Thank you very much i will close this as resolved