Jump to content

Recommended Posts

Posted

I am trying to figure out how to show discord only to logged-in members.  Right now it is visible on my front page.  Here is my current code for the discord section.  Any help would be greatly appreciated.  If it helps, I am on phpvms 5.5.2.72.  PHP version is 7.2.

 

 

<!--Begin Discord -->
<div class="blueIce-block clearfix">
<div class="blueIce-blockheader">
<h3 class="t">Discord</h3>
</div>
<div class="blueIce-blockcontent"><p>
<br>

<div align="center">

<iframe src="https://discord.com/widget?id=937311209793912923&theme=dark" width="240" height="500" allowtransparency="true" frameborder="0" sandbox="allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts"></iframe>

</div>
</p>
</div>
</div>
</div>
<!--End Discord -->

  • Administrators
Posted

If you have other areas of the site or specific modules that are only visible to members, look thru them for how they are restricted to members only. 

  • Administrators
Posted

As I recall, it has something to do with adding 

 

if(Auth::LoggedIn()) {

Do this

}else{

Do something different

}

 

"Do this" would be to display your discord stuff

"Do something else" would be to maybe return to the home page or display an error message

 

Posted
if (Auth::LoggedIn()) {
	// User is logged in
	// Do anything you wish here
} else {
	// User is not logged in, probably a quest visitor
	// Do another thing for quests if you need to
}

 

if (Auth::LoggedIn()) {
	// User is logged in
	// Do anything you need here
}

 

if (Auth::LoggedIn() == true) {
	// User is logged in
	// Do anything you need here
}

 

if (!Auth::LoggedIn()) {
	// User is NOT logged in
	// You can show a note here maybe like "Dear visitor, please Login or Register"
}

 

if (Auth::LoggedIn() == false) {
	// User is NOT logged in
	// You can show a note here maybe like "Dear visitor, please Login or Register"
}

 

Some examples ;)

Posted
<?php if (Auth::LoggedIn() == true) { ?>
  <div class="blueIce-block clearfix">
    <div class="blueIce-blockheader">
      <h3 class="t">Discord</h3>
    </div>
    <div class="blueIce-blockcontent" align="center">
      <iframe src="https://discord.com/widget?id=937311209793912923&theme=dark" width="240" height="500" allowtransparency="true" frameborder="0" sandbox="allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts"></iframe>
    </div>
  </div>
<?php } ?>

 

Something like this should do the trick.

  • Like 1
Posted
On 1/31/2022 at 6:49 AM, DisposableHero said:
<?php if (Auth::LoggedIn() == true) { ?>
  <div class="blueIce-block clearfix">
    <div class="blueIce-blockheader">
      <h3 class="t">Discord</h3>
    </div>
    <div class="blueIce-blockcontent" align="center">
      <iframe src="https://discord.com/widget?id=937311209793912923&theme=dark" width="240" height="500" allowtransparency="true" frameborder="0" sandbox="allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts"></iframe>
    </div>
  </div>
<?php } ?>

That worked like a charm!  Thank You very much.

  • Thanks 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...