Forum for discussing general topics related to Couch.
4 posts Page 1 of 1
Hi

I have added a logout link to my page

<cms:if k_logged_in>
Logout <a href="<cms:show k_logout_link />"><cms:show k_user_title /></a>
<cms:else />
<a href="<cms:show k_login_link />">Login</a>
</cms:if>


However, when the user clicks the logout link, it takes them to a login page
I would like the user to be redirected to the website's home page - index.html

Is there a way to do this?

Thanks in advance
Why not use something like default sample in login.php
Also I added some other code for redirects after login.

Code: Select all
 <cms:if k_logged_in >

        <!-- this 'login' template also handles 'logout' requests. Check if this is so -->
        <cms:set action="<cms:gpc 'act' method='get'/>" />
           
        <cms:if action='logout' >
            <cms:process_logout redirect=k_site_link />
        </cms:if>
      
      <cms:if k_user_access_level = '10' >
         <!-- super-admin just logged in? Welcome to backend.-->
         <cms:redirect "<cms:show k_admin_link /><cms:show k_admin_page/>?act=list&tpl=<cms:pages masterpage=k_user_template limit='1' skip_custom_fields='1' ><cms:show k_template_id /></cms:pages>"  />
      <cms:else_if k_user_access_level lt '10' />
         <!-- Normal user just logged. Welcome to your profile page -->
         <cms:redirect "<cms:link masterpage=k_user_template page=k_user_name />" />
      </cms:if>

   </cms:if>

Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
As an alternative, you can activate the 'extended-users' module which will make available several useful tags. We would be be interested in only <cms:login_link /> and <cms:logout_link /> tags that allow us to craft the login/logout links (e.g. using the 'redirect' parameter).

To activate the mentioned module, edit 'couch/addons/kfunctions.php' file (if this file is not found, rename the 'kfunctions.example.php' file there to 'kfunctions.php'). Uncomment (i.e. remove the beginning two slashes) from the following line in the file -
//require_once( K_COUCH_DIR.'addons/extended/extended-users.php' );

And now you can amend your code to make it as follows -
Code: Select all
<cms:if k_logged_in>
    Logout <a href="<cms:logout_link redirect=k_site_link />"><cms:show k_user_title /></a>
<cms:else />
    <a href="<cms:login_link />">Login</a>
</cms:if>

Please notice the 'redirect' parameter being used with <cms:logout_link /> tag above which will send the user to the site's homepage after logging out.

Hope it helps.
That worked perfectly thanks KK

Thanks also for your help Trendoman
4 posts Page 1 of 1
cron