Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

Display email address.

edited September 2007 in Vanilla 1.0 Help
I'm using $this->Context->Session->User->Name on certain texts of my forum which works fine. $this->Context->Session->User->Email on the other hand doesn't work. Nothing is displayed. The email address is public and exists. Thanks for your help.

Comments

  • Options
    Did you see this discussion?
  • Options
    Yes I did and I check the check box under the email address in the account. It's my test user and I see the address in the account page. The code I'm using is on a contact form. I can display the username who's logged in and would like to do the same for the email address with. $this->Context->Session->User->Email ??? Any idea? Thanks
  • Options
    If you look at the MembersPage add-on, you'll see how he gets the email address. What file are you changing?
  • Options
    I've just checked but the problem is that he uses his own sql queries instead of using vanilla's api. I'm sure that the $context->session->user->Email should work :-( Thanks for your help though... If more ideas ;-)
  • Options
    I use an extension I made to display user name and email in the Panel:
    if (in_array($Context->SelfUrl, array("index.php", "account.php", "categories.php", "comments.php", "post.php", "search.php", "settings.php"))) { function GetPanelLinkList(&$Context) { if ($Context->Session->UserID > 0) { if (!@$UserManager) $UserManager = $Context->ObjectFactory->NewContextObject($Context, "UserManager"); $AccountUserID = ForceIncomingInt("u", $Context->Session->UserID); if (!@$AccountUser) { $AccountUser = $UserManager->GetUserById($AccountUserID); $DispFName = $AccountUser->FirstName; $DispLName = $AccountUser->LastName; $DispName = $AccountUser->Name." ".$DispFName . " " . $DispLName . " ".$AccountUser->Email; } } else { $DispName = " "; } $PanelLinkList = ""; $PanelLinkList .= "<p>Hi ".$DispName."</p>"; return $PanelLinkList; } $Panel->AddString(GetPanelLinkList($Context),13); }
  • Options
    thanks for your help but i can't seem to get it to work correctly (not your addon, mine ;-) I wonder why the Name displays correctly though?
  • Options
    OK I made a test, in menu.php (theme vanilla) I changed the code to display the email address instead of the name (just as a test). It doesn't display the address either? See below, 4th line... Shouldn't it work? I checked your code and it seems to do the exact same thing as mine... echo '<div id="Session">'; if ($this->Context->Session->UserID > 0) { echo str_replace('//1', $this->Context->Session->User->Email, $this->Context->GetDefinition('SignedInAsX')).' (<a href="'.$this->Context->Configuration['SIGNOUT_URL'].'">'.$this->Context->GetDefinition('SignOut').'</a>)'; } else { echo $this->Context->GetDefinition('NotSignedIn').' (<a href="'.AppendUrlParameters($this->Context->Configuration['SIGNIN_URL'], 'ReturnUrl='.GetRequestUri()).'">'.$this->Context->GetDefinition('SignIn').'</a>)'; } echo '</div>'; $this->CallDelegate('PreHeadRender'); echo '<div id="Header"> <a name="pgtop"></a> <h1> '.$this->Context->Configuration['BANNER_TITLE'].' </h1> <ul>'; while (list($Key, $Tab) = each($this->Tabs)) { echo '<li'.$this->TabClass($this->CurrentTab, $Tab['Value']).'><a href="'.$Tab['Url'].'" '.$Tab['Attributes'].'>'.$Tab['Text'].'</a></li>'; } echo '</ul> </div>'; $this->CallDelegate('PreBodyRender'); echo '<div id="Body">';
  • Options
    edited June 2007
    It appears to me that there is no Email value in the Session->User object...? The Session->User object is populated by $UserManager->GetSessionDataById($this->UserID); and that function is:
    function GetSessionDataById($UserID) { $s = $this->Context->ObjectFactory->NewContextObject($this->Context, 'SqlBuilder'); $s->SetMainTable('User', 'u'); $s->AddJoin('Role', 'r', 'RoleID', 'u', 'RoleID', 'left join'); $s->AddJoin('Style', 's', 'StyleID', 'u', 'StyleID', 'left join'); $s->AddSelect(array('Name', 'UserID', 'RoleID', 'StyleID', 'CustomStyle', 'UserBlocksCategories', 'DefaultFormatType', 'Preferences', 'SendNewApplicantNotifications'), 'u'); $s->AddSelect(array('PERMISSION_SIGN_IN', 'PERMISSION_RECEIVE_APPLICATION_NOTIFICATION', 'PERMISSION_HTML_ALLOWED', 'Permissions'), 'r'); $s->AddSelect('Url', 's', 'StyleUrl'); $s->AddWhere('u', 'UserID', '', $UserID, '='); $User = $this->Context->ObjectFactory->NewContextObject($this->Context, 'User'); $UserData = $this->Context->Database->Select($s, $this->Name, 'GetSessionDataById', 'An error occurred while attempting to retrieve the requested user.'); if ($this->Context->Database->RowCount($UserData) == 0) { // This warning is in plain english, because at the point that // this method is called, the dictionary object is not yet loaded // (this is called in the context object's constructor when the session is started) $this->Context->WarningCollector->Add('The requested user could not be found.'); } else { while ($rows = $this->Context->Database->GetRow($UserData)) { $User->GetPropertiesFromDataSet($rows); } } return $this->Context->WarningCollector->Iif($User, false); }
    I guess you could add email in there..? Probably best to just grab the userID and use the proper look up function though..
  • Options
    Using Low-Call Vanilla? Try disabling.
This discussion has been closed.