Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Can I pass user token into url after registration?

  • InfoSolutionsProvider
  • InfoSolutionsProvider's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 3 months ago #147105 by InfoSolutionsProvider
Can I pass user token into url after registration? was created by InfoSolutionsProvider
Hello,

I want users to be able to click a link to immediately proceed with the survey after registering, without waiting for the confirmation email or leaving their browser. (The email still gets sent with the link, but my users are fairly impatient and the need has arisen to apply this workaround).

Following the instructions in the manual gets all the url parameters to work fine, except the unique token created when the user registered. I've tried many combinations, but the token returns blank, even when I can confirm that it's created in the database.

$publicurl/index.php?lang=en&sid={SID}&token={TOKEN}/newtest/Y

$publicurl/index.php/{SID}/lang/en/token/{TOKEN:TOKEN}/newtest/Y

$publicurl/index.php/{SID}/lang/en/token/{TOKEN}

$publicurl/index.php/{SID}/lang/en/token/{token}

I'm sure I'm missing something fairly simple, but can't for the life of me figure it out.

Thanks very much for your help.
The topic has been locked.
More
7 years 3 months ago #147154 by fvanderstarre
Replied by fvanderstarre on topic Can I pass user token into url after registration?
You might have a go with "{SURVEYURL}" (in case you haven't tried yet)?
It might well be that the TOKEN session variable is not set at registration time, e.g. for security reasons or because it will be sent by email anyway.
Good luck! Frank
The following user(s) said Thank You: InfoSolutionsProvider
The topic has been locked.
  • InfoSolutionsProvider
  • InfoSolutionsProvider's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 3 months ago #147156 by InfoSolutionsProvider
Replied by InfoSolutionsProvider on topic Can I pass user token into url after registration?
Thanks Frank. I already tried {SURVEYURL} but no joy. Probably because of your explanations.
In the end I had to change to an open survey without registration.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 3 months ago - 7 years 3 months ago #147211 by tpartner

In the end I had to change to an open survey without registration.

If you need immediate access after "registration", here are two possible workarounds:

1) Place mandatory email and name questions in the first survey group.

2) Create you own registration form and use the RemoteControl 2 API to create the token and redirect to the survey.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 7 years 3 months ago by tpartner.
The following user(s) said Thank You: InfoSolutionsProvider
The topic has been locked.
  • InfoSolutionsProvider
  • InfoSolutionsProvider's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 3 months ago #147268 by InfoSolutionsProvider
Replied by InfoSolutionsProvider on topic Can I pass user token into url after registration?
Thanks Tony.

As it happens, your suggested option 1 is what I ended up doing, having done away with the built in registration facility by making it an open survey.

I quite like the idea of the remote control API, and will tackle it on another project when I have a bit more time to get my head round it.

Best.

Fatai
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 3 months ago #147285 by DenisChenu
Thnik best is to create a plugin for this.

Using some event in github.com/LimeSurvey/LimeSurvey/blob/ma...gisterController.php

Or take insipration of this old code framagit.org/SondagePro-LimeSurvey-plugin/replaceRegister

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
More
6 years 8 months ago #157727 by Pandar
Hey! I've done this. I editted this file:
application/controllers/RegisterControllers.php
• Go to the public function getTokenId($iSurveyId).
• At the end of this function is a line where $sMailMessage can be replaced.

$this->sMailMessage= "<div id='wrapper' class='message tokenmessage'>"
. "<p>".gT("Thank you for registering to participate in this ballot.")."</p>\n"
. "<p>".gT("An email has been sent to the address you provided with an access link to this ballot.")."</p>\n"

//You can either replace, add or comment out what you don't need, but this is where you would insert something like this:

. "<p>".gT("Click Here to Proceed:")."<a href=' www.yoururl.com/index.php/12345/lang/en/token/$oToken- >token'>"."Access Survey Here."."

"
. "<p>".sprintf(gT("Survey administrator %s (%s)"),$aSurveyInfo,$aSurveyInfo)."</p>"
. "</div>\n";


return $oToken->tid;

}
}

The $oToken->tid was the clue. I set the message to display this and it showed me the ID from the database. Then I realized $oToken is an object. All I had to do was find the variable containing the token values. Scrolling up, I found $oToken->token and gave that a try. I think this will only work within this php file though.

Is this what you were looking for? PS. if this works for you after you edit your files, be sure to run backups in case your updates are automatic.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose