Pulling Gender

Started by dobie, August 02, 2009, 07:24:15 PM

Previous topic - Next topic

dobie

hi i have this problem i cannot get gender to show elsewhere i have this at moment

require_once("../ccn/SSI.php");

global $context, $settings, $scripturl, $txt, $db_prefix, $user_info;
if (!$context['user']['is_guest']) {
             // gets just the users id
             $id = $user_info['id'];
             // gets the entire link: e.g. (for Admin would output) http://xxxxx.xxxx/index.php?action=profile;u=1
             $ahrefLink = $scripturl . '?action=profile;u=';
   // Get username as a link to their profile automatically, from id...
   ssi_fetchMember($user_info['id']['gender']);
loadMemberContext($userid);


then im calling it like this so members will be shown as male or female

$memberContext[$user_info['id']]['gender']['name'];

but this does not work so i am happy if someone can point me in right direction

thanx

JBlaze

<?phprequire_once("../ccn/SSI.php");function get_memberData(){    global $context, $settings, $scripturl, $txt, $db_prefix, $user_info;        if (!$context['user']['is_guest'])        $member = array();        $request = $smcFunc['db_query']('', '          SELECT id_member, real_name, gender          FROM {db_prefix}members          WHERE id_member = {int:id_member}',          array(            'id_member' => $user_info['id'],          )        );        $smcFunc['db_free_result']($request);        if (isset($user_info['id']))        return $member;    while ($row = $smcFunc['db_fetch_assoc']($request))    {        $member = array(          'id' => $row['id_member'],          'name' => array(            'text' => $row['real_name'],            'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" title="View the profile of ' . $row['real_name'] . '">' . $row['real_name'] . '</a>',            'href' => $scripturl . '?action=profile;u=' . $row['id_member'],          ),          'gender' => array(            'text' => $row['gender'],            'image' => '<img src="' . $settings['images_url'] . '/' . $row['gender'] . '.gif" alt="' . $row['gender'] . '" />',          ),        );     }}// output the data$members = get_memberData();foreach ($members as $member){  echo ' '; // Put your data strings here// $member['id']// $member['name']['text'], $member['name']['link'], $member['name']['href']// $member['gender']['text'], $member['gender']['image']}?>

This is a bit more than just calling $context variables, but is more flexible for what you need.
Jason Clemons
Former Team Member 2009 - 2012

tyty1234

Sadly JBlaze, your function didn't work for me. :P

So, I turned your function into an easier one, without the db_queries. :P


<?phprequire(dirname(__FILE__) . '/ccn/SSI.php');function get_memberData(){ global $context, $user_info, $memberContext; // Only show the data if they are a member. if (!$context['user']['is_guest']) { // Load everything needed to get the gender. Basically, load their whole profile. loadMemberData($user_info['id'], false, 'profile'); loadMemberContext($context['user']['id']); $context['member'] = $memberContext[$context['user']['id']]; // Put the data into an array. foreach($context['member'] as $key => $value) { $member[$key] = $value; } // Return the data. return $member; } else { $member = array(); return $member; }}// Put the data into ths variable.$memberData = get_memberData();echo $memberData['gender']['name'] . '&nbsp;' . $memberData['gender']['image'];/* You can get more data from here. Here are some examples.$memberData['name'] (for member name)$memberData['id'] (for member id)$memberData['link'] (link to member profile)*/?>
My Activity: Inactive
My Links: tyty1234's SMF Site | SMF Package Parser | SMF Helper | My Mods [5]
Subscribe to my SMF blog for updates
PMs for support will not be accepted, unless requested otherwise.

JBlaze

Meh fair enough. That's what happens when you rip from your own code and *think* it'll work...

Nice job tyty :)
Jason Clemons
Former Team Member 2009 - 2012

tyty1234

My Activity: Inactive
My Links: tyty1234's SMF Site | SMF Package Parser | SMF Helper | My Mods [5]
Subscribe to my SMF blog for updates
PMs for support will not be accepted, unless requested otherwise.

dobie

thanx to both  sadly it dont work for me i am trying to pull gender from database which in turns gives a my users a male ot female  icon im soooooooooooooo lost any help would be appreciated

tyty1234

did you try my script? or JBlaze's?
My Activity: Inactive
My Links: tyty1234's SMF Site | SMF Package Parser | SMF Helper | My Mods [5]
Subscribe to my SMF blog for updates
PMs for support will not be accepted, unless requested otherwise.

dobie

i tried yours tyty and blazes what i have got is avchat3.0 chat system and what im after is the gender part of intergration to be picked up so a woman will be shown as a female icon and male etc this is what i have at moment

<?php require_once("../ccn/SSI.php"); global $context, $settings, $scripturl, $txt, $db_prefix, $user_info;if (!$context['user']['is_guest']) {             // gets just the users id             $id = $user_info['id'];             // gets the entire link: e.g. (for Admin would output) http://xxx.xxxxx.com/index.php?action=profile;u=1             $ahrefLink = $scripturl . '?action=profile;u=';   // Get username as a link to their profile automatically, from id...   ssi_fetchMember($user_info['id']['gender']);}

tyty1234

are you trying to include the gender on the chat page, or are trying to pull the gender from the chat system?
My Activity: Inactive
My Links: tyty1234's SMF Site | SMF Package Parser | SMF Helper | My Mods [5]
Subscribe to my SMF blog for updates
PMs for support will not be accepted, unless requested otherwise.

dobie

hi tyty i am trying to pull the gender from chat as its has male and female but i want to use my users gender from smf

i have a xml code <xliff version="1.0" xml:lang="en">

  <file datatype="plaintext" original="videorecorder.fla" source-language="EN">
    <header></header>
    <body>
      <trans-unit id="000" resname="IDS_BT_CLOSE">
        <source>Close</source>
      </trans-unit>
      <trans-unit id="000a" resname="IDS_BT_CANCEL">
        <source>Cancel</source>
      </trans-unit>
      <trans-unit id="001" resname="IDS_MALE">
        <source>Male</source>
      </trans-unit>
      <trans-unit id="002" resname="IDS_FEMALE">
        <source>Female</source>
      </trans-unit>
      <trans-unit id="003" resname="IDS_COUPLE">
        <source>Couple</source>


i have users profile working correctly but i just cant get this male and female icon in chat

dobie

N3RVE

Do you require any further support?
I'll move this to a more appropriate section where it will get the attention it deserves :).

-[n3rve]
Ralph "[n3rve]" Otowo
Former Marketing Co-ordinator, Simple Machines.
ralph [at] simplemachines [dot] org                       
Quote"Somewhere, something incredible is waiting to be known." - Carl Sagan

Advertisement: