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.
Dispay Username Across Multiple Scripts
Hi,
I have a fairly large site. I got vanilla working with my wordpress blog. I have several other scripts that do not require user management. What I'd like to do is have the vanilla Sign-in/Sign Out and Register links display sitewide so that when a users signs-in, it will display Username (Sign Out).
I've attempted to do this with the Page Manager ext to no avail. Can anyone point me in the right direction?
Thanks
I have a fairly large site. I got vanilla working with my wordpress blog. I have several other scripts that do not require user management. What I'd like to do is have the vanilla Sign-in/Sign Out and Register links display sitewide so that when a users signs-in, it will display Username (Sign Out).
I've attempted to do this with the Page Manager ext to no avail. Can anyone point me in the right direction?
Thanks
0
Comments
Have a look at the first few lines of Vanilla's
index.php
:include("appg/settings.php"); $Configuration['SELF_URL'] = 'index.php'; include("appg/init_vanilla.php"); // You might consider changing this to `init_ajax.php` for faster execution
That will start the core of Vanilla and give you access to
$Context
and$Context->Session
which holds the user's information.For displaying the links, take a look at
themes/menu.php
near the top:echo '<div id="Session">'; if ($this->Context->Session->UserID > 0) { echo str_replace('//1', $this->Context->Session->User->Name, $this->Context->GetDefinition('SignedInAsX')) . ' (<a href="' . FormatStringForDisplay(AppendUrlParameters( $this->Context->Configuration['SIGNOUT_URL'], 'FormPostBackKey=' . $this->Context->Session->GetCsrfValidationKey() )) . '">'.$this->Context->GetDefinition('SignOut').'</a>)'; } else { echo $this->Context->GetDefinition('NotSignedIn') . ' (<a href="' . FormatStringForDisplay(AppendUrlParameters( $this->Context->Configuration['SIGNIN_URL'], 'ReturnUrl='. urlencode(GetRequestUri(0)))) . '">'.$this->Context->GetDefinition('SignIn').'</a>)'; } echo '</div>';
That should get you to what you want.
If you want to hide your pages from unregistered users (if you have public browsing turned off), you can add this line right after the first 3 lines that start the core:
$Context->Session->Check($Context);
I hope this helps.