6 Replies Latest reply: Oct 31, 2012 10:23 AM by jymcconn RSS

    content on login for the forum

    kenneth_rapp Community Member

      I built a login form for the forum into the dynamic menu for my site, so that when you select 'forum' from the menu, you can log in directly.

       

      What I would like to do is be able to tell when they're logged in already and, if so, have that submenu show a topics list or something (currently it still shows the login even after they're already logged in.) Is there a way to get a forum logged in status that I can add to a template to do this? The only other idea I have would be to call the forum page by ajax and parse the html (which would be different for logged in users as not) but that would be ugly.

        • 1. Re: content on login for the forum
          mattdwm Community Member

          Did you ever figure this out? I need to do something similar.

          • 2. Re: content on login for the forum
            kenneth_rapp Community Member

            Yes actually, I just figured it out yesterday. The only answer I could find was the one I wanted to avoid, though.

             

            The basic process is to pull the forum page in with an ajax call with jQuery. There's a layer in the forum document with the id 'user' which has different properties whether someone is currently logged in or not. If they're logged in, it will contain a link to logout, and if they're not, it won't. So I used this as a test. Here is the function I made, I left out and commented the parts to add your own code for if logged in and if logged off:

            function GetForumLoginState(){
                           forumget = $.ajax({
                                url: '/ForumRetrieve.aspx',
                                dataType:'html',
                                async:false,
                                data: {
                                     'ForumID':12345
                                }
                           });
            
                           forumget.done(function(data){
                                loginstatus = $(data).find('li.user:has(a[href="/LogOutProcess.aspx"])').html();
                                
                                if(loginstatus == null){
                                     // they're logged out
                                }
                                else{
                                     // they're logged in
                                }
                           });
                      }
            

            ... replacing it with your own forum id too. Running this somewhere will show you whether someone is currently logged in or not.

            • 3. Re: content on login for the forum
              tmikaeld Community Member

              Why not use the module that shows if you are logged in or not?

               

              {module_isloggedin}

               

              It will show 1 if logged in 0 if not.

              • 4. Re: content on login for the forum
                jymcconn Community Member

                I have used the module_isLoggedIn, but find that is shows 1 if I am logged in to any area. Do you know of a way to ask if user is logged into a specific zone? Thanks for any insight.

                Janice

                • 5. Re: content on login for the forum
                  Mihai_Tica Employee Hosts

                  I am afraid at the moment there is no way to "tell" which secure zone a CRM contact is logged into out of the box, as you notived the module_isLoggedin can only be used to determine whether the current user is logged in or not.

                   

                  This is what I was thinking though, imagine this setup:

                   

                  -2 login forms for 2 different secure zones

                  -the secure zones have 2 blank landing pages that will act as proxies (let's call them proxyA.html and proxyB.html), will detail this further below

                  -on either page put a javascript snippet that redirects the site visitor to the page you need them to be redirected after logging in (let's call it pageA.html) and adds a query parameter in the URL

                  -on pageA.html you will need to have a javascript snippet that reads the parameter in the URL and does something based on its value. Basically at this point based on the parameter in the URL you can tell which secure zone form the site visitor used to login

                   

                  In this setup you basically use the proxy pages to "mark" the URL with a parameter you can later use to link that site visitor to the secure zone form he used to login.

                   

                  What do you think, would this type of setup be useful?

                  • 6. Re: content on login for the forum
                    jymcconn Community Member

                    Yes, it helped. I'm submitting a booking form with an associated web app item form using ajax. I needed to differentiate between member logged in and anonymous logged in so I could test and not log out a member. Thanks to another thread, I saw that if the web app is in the secure member zone, then a member doesn't need the anonymous log in.

                    I have had some intermittent problems with the web app item not submitting - can't find a pattern to pin down the cause. On Monday, 2 of 7 bookings didn't have the associated web app item created. Thanks for the help.