The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

Links that can only be seen by people logged in

View previous topic View next topic Go down

In progress Links that can only be seen by people logged in

Post by njaguar on December 10th 2013, 5:57 am


I'd like to remove the "register" link when the person logs in, but want it to be there if a person isn't logged in

also 




I want to make it say log in when the person isn't logged in but say log out when the person is logged in. 
I'd like to hide the other three things to only be seen if the person has logged in, I'm Using announcements to make this nav/tool bar.

njaguar
Forumember

Male Posts : 113
Reputation : 1
Language : English
Location : United Kingdom

http://d4jsp.forumotion.com/

Back to top Go down

In progress Re: Links that can only be seen by people logged in

Post by njaguar on December 12th 2013, 1:02 pm

bump

njaguar
Forumember

Male Posts : 113
Reputation : 1
Language : English
Location : United Kingdom

http://d4jsp.forumotion.com/

Back to top Go down

In progress Re: Links that can only be seen by people logged in

Post by Ange Tuteur on December 12th 2013, 3:00 pm

Hello njaguar,

You can do this with a script by checking if the user is logged in or out.

Administration Panel > Modules > Javascript codes management > create a new script

Name : What you wish
Placement : In all the pages
Code:
jQuery(function () {
    /*User logged in*/
    if (_userdata['session_logged_in']) {
        jQuery('#menuitem').remove();
    }
    /*User logged out*/
    if (!_userdata['session_logged_in']) {
        jQuery('#menuitem').remove();
    }
})

I've added comments so you know which is which. The second if statement is inverted, it runs if 'session_logged_in' is false. i.e. logged out

To add your menu items to these list is simple I'll give an example below.

My menu :
Code:
<a id="menu_register" href="/register">Register</a> | <a id="menu_login" href="/login">Login</a>

To remove those for users logged in I would add my links ID's to the first if statement :
Code:
jQuery(function () {
    /*User logged in*/
    if (_userdata['session_logged_in']) {
        jQuery('#menu_register, #menu_login').remove();
    }
    /*User logged out*/
    if (!_userdata['session_logged_in']) {
        jQuery('#menuitem').remove();
    }
})

You can use multiple ID's as long as they're separated by a comma. Wink

Ange Tuteur
Forumaster

Male Posts : 13028
Reputation : 2704
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

In progress Re: Links that can only be seen by people logged in

Post by njaguar on December 12th 2013, 3:15 pm

I can't get it to work, pmed

njaguar
Forumember

Male Posts : 113
Reputation : 1
Language : English
Location : United Kingdom

http://d4jsp.forumotion.com/

Back to top Go down

In progress Re: Links that can only be seen by people logged in

Post by Ange Tuteur on December 12th 2013, 3:22 pm

For your links on the navbar, do they have an ID or class name ?

Ange Tuteur
Forumaster

Male Posts : 13028
Reputation : 2704
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

In progress Re: Links that can only be seen by people logged in

Post by njaguar on December 12th 2013, 3:25 pm

I'm not sure, I have made my own Nav bar, which is coded in announcements. http://d4jsp.forumotion.com/ this is my forum

njaguar
Forumember

Male Posts : 113
Reputation : 1
Language : English
Location : United Kingdom

http://d4jsp.forumotion.com/

Back to top Go down

In progress Re: Links that can only be seen by people logged in

Post by Ange Tuteur on December 12th 2013, 3:28 pm

Oh I see now, it's because you have the toolbar deactivated. Since you're not using that I'll try another method.

Ange Tuteur
Forumaster

Male Posts : 13028
Reputation : 2704
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

In progress Re: Links that can only be seen by people logged in

Post by njaguar on December 12th 2013, 3:36 pm

thanks!

njaguar
Forumember

Male Posts : 113
Reputation : 1
Language : English
Location : United Kingdom

http://d4jsp.forumotion.com/

Back to top Go down

In progress Re: Links that can only be seen by people logged in

Post by Ange Tuteur on December 12th 2013, 3:42 pm

Try this script :
We're checking for the logout id from the orginal navbar, its the same setup, but just another ID. I'm unsure if it will work properly depending on how you hid the old navbar, but give it a try nonetheless. Wink

Remove the old code and replace with this :
Code:
   jQuery(function () {
        /*User logged in*/
        if (document.getElementById('#logout')) {
            jQuery('#menu_register, #menu_login').remove();
        }
        /*User logged out*/
        if (!document.getElementById('#logout')) {
            jQuery('#menuitem').remove();
        }
    })

Ange Tuteur
Forumaster

Male Posts : 13028
Reputation : 2704
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

In progress Re: Links that can only be seen by people logged in

Post by njaguar on December 12th 2013, 3:44 pm

I'll try it will i think i just made it show them as images then hide the images

njaguar
Forumember

Male Posts : 113
Reputation : 1
Language : English
Location : United Kingdom

http://d4jsp.forumotion.com/

Back to top Go down

In progress Re: Links that can only be seen by people logged in

Post by njaguar on December 12th 2013, 3:45 pm

Doesn't work. It stops my other Java codes

njaguar
Forumember

Male Posts : 113
Reputation : 1
Language : English
Location : United Kingdom

http://d4jsp.forumotion.com/

Back to top Go down

In progress Re: Links that can only be seen by people logged in

Post by Ange Tuteur on December 12th 2013, 4:13 pm

Please don't double/triple post. Your post need to be separated by 24 hours before bumping, replying or adding more information. Please use the edit button instead!

I invite you to review the rules.


Remove the scripts I gave you for now. Hmm.. the way you're doing this is going to be difficult since those two methods aren't going to be applicable. I will have to play around and see if I can come up with another method.

Ange Tuteur
Forumaster

Male Posts : 13028
Reputation : 2704
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

In progress Re: Links that can only be seen by people logged in

Post by njaguar on December 15th 2013, 6:53 pm

Bump

njaguar
Forumember

Male Posts : 113
Reputation : 1
Language : English
Location : United Kingdom

http://d4jsp.forumotion.com/

Back to top Go down

In progress Re: Links that can only be seen by people logged in

Post by njaguar on December 18th 2013, 6:10 pm

bump

njaguar
Forumember

Male Posts : 113
Reputation : 1
Language : English
Location : United Kingdom

http://d4jsp.forumotion.com/

Back to top Go down

In progress Re: Links that can only be seen by people logged in

Post by Legolas on December 19th 2013, 7:51 pm

Hello,
What codes have you added ? Also, it'll be okay if you'll post your forum's address!

Legolas
Forumember

Male Posts : 262
Reputation : 33
Language : English

http://www.daily-support.org

Back to top Go down

In progress Re: Links that can only be seen by people logged in

Post by njaguar on December 19th 2013, 10:17 pm

@Legolas wrote:Hello,
What codes have you added ? Also, it'll be okay if you'll post your forum's address!
 This is my forum (http://d4jsp.forumotion.com/

This is the code i use, I have it set in the announcement part! 

Code:
<span style="font-size: 10px;"></span>
<div class="fixedPosition"><span style="font-size: 10px;"></span>
   <div class="fixedPosition"><span style="font-size: 10px;"></span>
      <div style="text-align: left;"><span style="font-size: 10px;"></span>
         <div class="head"><span style="font-size: 10px;"></span>
            <div class="lH" style="">
               <div class="lB">
                  <div class="lD">d4jsp
                  </div>
                  <div class="lS">
                      Gaming and Trading Community
                  </div>
               </div>
               <div class="lM">
                  <div class="lD"><a href="http://d4jsp.forumotion.com/">d4jsp</a>
                  </div>
                  <div class="lS">
                      Gaming and Trading Community
                  </div>
               </div>
               <!--                    BEGIN switch_user_logged_in                    -->
            </div><span style="font-size: 10px;"></span>
            <div class="lX">
               <div class="lL">
                  <div class="sX s0b">
                  </div><a href="statistics.php"><img src="http://i58.servimg.com/u/f58/18/55/79/31/ss13.png" border="none" />Statistics</a><br />
                  <div class="sX s0d">
                  </div><a href="/memberlist"><img src="http://i58.servimg.com/u/f58/18/55/79/31/online10.png" border="none" />Memberlist</a>
               </div>
               <div class="lL">
                  <div class="sX s0f">
                  </div><a href="http://d4jsp.forumotion.com/search"><img src="http://i58.servimg.com/u/f58/18/55/79/31/ss10.png" border="none" />Search</a><br />
                  <div class="sX s0f">
                  </div><a href="http://d4jsp.forumotion.com/buy-credits"><img src="http://i58.servimg.com/u/f58/18/55/79/31/ss14.png" border="none" />Donate</a>
               </div>
               <div class="lL">
                  <div class="sX s0b">
                  </div><a href="http://d4jsp.forumotion.com/h1-shop"><img src="http://i58.servimg.com/u/f58/18/55/79/31/ss14.png" border="none" />Shop</a><br />
                  <div class="sX s0b">
                  </div><a href="http://d4jsp.forumotion.com/t29-bank-here-is-where-you-can-control-your-forum-gold"><img src="http://i58.servimg.com/u/f58/18/55/79/31/ss14.png" border="none" />Forum Bank</a>
               </div>
               <div class="lL">
                  <div class="sX s0a">
                  </div><a href="http://d4jsp.forumotion.com/"><img src="http://i58.servimg.com/u/f58/18/55/79/31/ss12.png" border="none" />Return to Forum</a><br />
                  <div class="sX s0f">
                  </div><a href="http://d4jsp.forumotion.com/faq"><img src="http://i58.servimg.com/u/f58/18/55/79/31/help10.png" border="none" />Help and support</a>
               </div>
            </div><span style="font-size: 13px;"></span>
            <div class="c" style="">
            </div><span style="font-size: 13px;"></span>
         </div>
         <div class="bar">
            <ul class="barR">
               <li><span style="font-size: 13px;"><a href="http://d4jsp.forumotion.com/privmsg?folder=inbox">Private Messages</a></span><a href="http://d4jsp.forumotion.com/search?search_id=egosearch">Posts: {USERCOUNTPOST}</a>
               </li>
               <li><span style="font-size: 13px;"><a href="http://d4jsp.forumotion.com/f15-complaints-warn-removal">Complaints/Warn Removal</a></span>
               </li>
               <li><span style="font-size: 13px;"><a href="http://d4jsp.forumotion.com/groups">Usergroups</a></span>
               </li>
               <li><span style="font-size: 13px;"><a href="http://d4jsp.forumotion.com/search?search_id=favouritesearch">Topic Tracker</a></span>
               </li>
            </ul>
            <ul class="barL">
               <li><span style="font-size: 13px;">Hello,{USERLINK}</span>
               </li><a href="/register">Register</a><a href="/login?logout=1">Log out</a>
               <li><span style="font-size: 13px;"><a href="http://d4jsp.forumotion.com/profile?mode=editprofile">Settings</a></span>
               </li>
            </ul>
            <!--                  END switch_user_logged_in                  -->
            <div class="c">
            </div>
         </div>
      </div>
   </div>
</div>

njaguar
Forumember

Male Posts : 113
Reputation : 1
Language : English
Location : United Kingdom

http://d4jsp.forumotion.com/

Back to top Go down

In progress Re: Links that can only be seen by people logged in

Post by Legolas on December 19th 2013, 10:17 pm

Have you added these codes in the announcements ?  bwi 

Legolas
Forumember

Male Posts : 262
Reputation : 33
Language : English

http://www.daily-support.org

Back to top Go down

In progress Re: Links that can only be seen by people logged in

Post by njaguar on December 19th 2013, 10:23 pm

@Legolas wrote:Have you added these codes in the announcements ?  bwi 


Yes look....

njaguar
Forumember

Male Posts : 113
Reputation : 1
Language : English
Location : United Kingdom

http://d4jsp.forumotion.com/

Back to top Go down

In progress Re: Links that can only be seen by people logged in

Post by Legolas on December 19th 2013, 10:26 pm

Ohh..
Please post your overall_header.
I'll come back tomorrow with the solve for this. Also, please post what links you want to hide when users are not logged in. Thanks!

Legolas
Forumember

Male Posts : 262
Reputation : 33
Language : English

http://www.daily-support.org

Back to top Go down

In progress Re: Links that can only be seen by people logged in

Post by njaguar on December 19th 2013, 10:29 pm


    Log out<---- want to hide this when people aren't logged in I



      Register<--- hid this when they ARE logged in 




njaguar
Forumember

Male Posts : 113
Reputation : 1
Language : English
Location : United Kingdom

http://d4jsp.forumotion.com/

Back to top Go down

In progress Re: Links that can only be seen by people logged in

Post by Legolas on December 20th 2013, 10:21 am

Can you post your overall_header too ? I want to include these links in it.

Legolas
Forumember

Male Posts : 262
Reputation : 33
Language : English

http://www.daily-support.org

Back to top Go down

In progress Re: Links that can only be seen by people logged in

Post by levy on December 20th 2013, 11:20 am

FM have some comments in HTML , which allow you to see only logged in peoples or only logged out , so the comments are:

for your code , the script is this :

Code:
<!-- BEGIN switch_user_logged_out -->
<!-- END switch_user_logged_out -->

<!-- BEGIN switch_user_logged_in -->
<!-- END switch_user_logged_in -->

Code:
<span style="font-size: 10px;">
</span>
<div class="fixedPosition">
   <span style="font-size: 10px;">
   </span>
   <div class="fixedPosition">
      <span style="font-size: 10px;">
      </span>
      <div style="text-align: left;">
         <span style="font-size: 10px;">
         </span>
         <div class="head">
            <span style="font-size: 10px;">
            </span>
            <div style="" class="lH">
               <div class="lB">
                  <div class="lD">d4jsp
                  </div>
                  <div class="lS">
                      Gaming and Trading Community
                  </div>
               </div>
               <div class="lM">
                  <div class="lD">
                     <a href="http://d4jsp.forumotion.com/">d4jsp</a>
                  </div>
                  <div class="lS">
                      Gaming and Trading Community
                  </div>
               </div>
               <!--                    BEGIN switch_user_logged_in                    -->
            </div><span style="font-size: 10px;"></span>
            <div class="lX">
               <div class="lL">
                  <div class="sX s0b">
                  </div><a href="statistics.php"><img border="none" src="http://i58.servimg.com/u/f58/18/55/79/31/ss13.png" />Statistics</a><br />
                  <div class="sX s0d">
                  </div><a href="/memberlist"><img border="none" src="http://i58.servimg.com/u/f58/18/55/79/31/online10.png" />Memberlist</a>
               </div>
               <div class="lL">
                  <div class="sX s0f">
                  </div><a href="http://d4jsp.forumotion.com/search"><img border="none" src="http://i58.servimg.com/u/f58/18/55/79/31/ss10.png" />Search</a><br />
                  <div class="sX s0f">
                  </div><a href="http://d4jsp.forumotion.com/buy-credits"><img border="none" src="http://i58.servimg.com/u/f58/18/55/79/31/ss14.png" />Donate</a>
               </div>
               <div class="lL">
                  <div class="sX s0b">
                  </div><a href="http://d4jsp.forumotion.com/h1-shop"><img border="none" src="http://i58.servimg.com/u/f58/18/55/79/31/ss14.png" />Shop</a><br />
                  <div class="sX s0b">
                  </div><a href="http://d4jsp.forumotion.com/t29-bank-here-is-where-you-can-control-your-forum-gold"><img border="none" src="http://i58.servimg.com/u/f58/18/55/79/31/ss14.png" />Forum Bank</a>
               </div>
               <div class="lL">
                  <div class="sX s0a">
                  </div><a href="http://d4jsp.forumotion.com/"><img border="none" src="http://i58.servimg.com/u/f58/18/55/79/31/ss12.png" />Return to Forum</a><br />
                  <div class="sX s0f">
                  </div><a href="http://d4jsp.forumotion.com/faq"><img border="none" src="http://i58.servimg.com/u/f58/18/55/79/31/help10.png" />Help and support</a>
               </div>
            </div><span style="font-size: 13px;"></span>
            <div style="" class="c">
            </div><span style="font-size: 13px;"></span>
         </div>
         <div class="bar">
            <ul class="barR">
               <li>
                  <span style="font-size: 13px;"><a href="http://d4jsp.forumotion.com/privmsg?folder=inbox">Private Messages</a></span><a href="http://d4jsp.forumotion.com/search?search_id=egosearch">Posts: {USERCOUNTPOST}</a>
               </li>
               <li>
                  <span style="font-size: 13px;"><a href="http://d4jsp.forumotion.com/f15-complaints-warn-removal">Complaints/Warn Removal</a></span>
               </li>
               <li>
                  <span style="font-size: 13px;"><a href="http://d4jsp.forumotion.com/groups">Usergroups</a></span>
               </li>
               <li>
                  <span style="font-size: 13px;"><a href="http://d4jsp.forumotion.com/search?search_id=favouritesearch">Topic Tracker</a></span>
               </li>
            </ul>
            <ul class="barL">
               <li>
                  <span style="font-size: 13px;">Hello,{USERLINK}</span>
               </li><a href="/register">Register</a><a href="/login?logout=1">Log out</a>
               <li>
                  <span style="font-size: 13px;"><a href="http://d4jsp.forumotion.com/profile?mode=editprofile">Settings</a></span>
               </li>
            </ul>
            <!--                  END switch_user_logged_in                  -->
            <div class="c">
            </div>
         </div>
      </div>
   </div>
</div>

levy
Hyperactive

Male Posts : 2582
Reputation : 345
Language : Romanian, English
Location : criticize artwork, not people!

http://help.forumotion.com/

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum