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 –>
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.
I’ll try that again. I tried that earlier this morning. It ended up messing my whole page up. Thank You.
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
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
\<?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.
1 Like
Thans for the help. I will try that.
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.
1 Like