Websitemembership Plugin v1.10 Redirection Problem

14 posts by 4 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: June 4, 2013   (RSS)

Hi

I am using CMSB v5.3 (Build 1040) and Website Membership Plugin v1.10

The problem I am having is with this line of code in websiteMembership.php

// After login, user gets redirected to the last page they were on (if defined), the url below, or to /
$GLOBALS['WEBSITE_LOGIN_POST_LOGIN_URL']  = '/profile.php';

As you can see, I have set the post login url to '/profile.php', however it does not work.  Instead I am re-directed to '/login.php'.

Can anyone help?

--
northernpenguin
Northern Penguin Technologies

"Any sufficiently advanced technology
is indistinguishable from magic."
........Arthur C. Clarke

By gkornbluth - May 24, 2013

Hi,

The plugin code looks fine, do you experience the problem from all your protected pages or just from one single page?

Just in case, the code that's required in all protected viewers is:

<?php if (!$CURRENT_USER) { websiteLogin_redirectToLogin(); } ?>

It's just after the load viewer library call.

Best,

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Jerry:  the issue has nothing to do with any of my protected pages.  They all work fine.  The only issue is if I place a file name in websiteMembership.php to redirect users to profile.php after login, this does not occur.

it should, but it doesn't for some reason.

ragi

--
northernpenguin
Northern Penguin Technologies

"Any sufficiently advanced technology
is indistinguishable from magic."
........Arthur C. Clarke

Thanks Jerry!  Appreciate it.

ragi

--
northernpenguin
Northern Penguin Technologies

"Any sufficiently advanced technology
is indistinguishable from magic."
........Arthur C. Clarke

By gkornbluth - May 26, 2013 - edited: May 26, 2013

Hi Raji,

The $GLOBALS['WEBSITE_LOGIN_POST_LOGIN_URL']  = '/my_page/php';  worked for me using 2.53 and 1.10, but only after I cleared the cache and all the cookies associated with the web site that I was working with.

If I remember rightly, there were/are issues with destroying session cookies in 2.53 (that will hopefully be addressed in 2.54)

Djulia noted in a post about this that: "If you use version 2.53, you must check that the variable $GLOBALS [“WSM_SEPARATE_LOGIN”] is on "false" (in websiteMembership)."

Hope these clues lead to success.

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

By gregThomas - May 28, 2013

Hi Ragi,

Are you setting the lastUrl cookie at all? 

setPrefixedCookie('lastUrl', thisPageUrl());

If the lastUrl cookie is set, the user will be taken to that page as opposed to the page defined in $GLOBALS['WEBSITE_LOGIN_POST_LOGIN_URL']. 

Thanks

Greg

Greg Thomas







PHP Programmer - interactivetools.com

Greg:  where do I set lastUrl cookie?

ragi

--
northernpenguin
Northern Penguin Technologies

"Any sufficiently advanced technology
is indistinguishable from magic."
........Arthur C. Clarke

By gregThomas - May 28, 2013 - edited: May 28, 2013

Hi Ragi,

The lastUrl cookie is an optional setting you can use in CMS Builder that is used to redirect the user to a different page to the one set in the websiteMembership.php after logging in. For example, you might set it on a detail page like this:

  // load viewer library
  $libraryPath = 'cmsAdmin/lib/viewer_functions.php';
  $dirsToCheck = array('/home/koloa/public_html/','','../','../../','../../../');
  foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
  if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

  if(!@$CURRENT_USER){
    setPrefixedCookie('lastUrl', thisPageUrl());
    redirectBrowserToLogin('/login.php');
  }

So in the example above if the user wasn't logged in, you'd set the lastUrl cookie to the current page URL, then redirect the user to the login page. Then once they'd logged in they'd be taken back to the detail page they were on.

This can sometimes cause issues as the cookie isn't removed after the user leaves the page they are currently on, so if they navigate around the site for a bit, then log in they are taken to a page they didn't expect. I thought this might be happening with your page, but if you've not set the lastUrl cookie, so it must be something different.  

Could you fill out a second level support request for me? You can find the form here:

https://www.interactivetools.com/support/email_support_form.php

Then I can take a closer look at what is causing the issue.

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By gregThomas - May 29, 2013

Hi Ragi,

I've found out what the issue was. In the code generator for the website membership plugin the lastUrl cookie is automatically set to take the user to the previous page they were on after login. To stop this happening I removed the following lines of code from login.php:

    // redirect to profile page after after signing up
    setPrefixedCookie('lastUrl', $GLOBALS['WEBSITE_LOGIN_PROFILE_URL']);

This stops the lastUrl cookie from being generated and takes the user to the post login page set in the website membership plugin. 

Let me know if you have any questions.

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com