Does anyone know how this parameter works, it seems to not be for form values. Its supposed to be a JSON object that populates the GET parameters on the redirect page but i can’t put in the dynamic values from the form. And so far I haven’t been able to find any examples of its use.
This doesn’t work
I’m gonna be honest here, I don’t think basically anyone here knows how this works
You’re breaking new ground!
As for the JSON, maybe I am misunderstanding you, the JSON would be saved temporarily by Register snippet to be available throughout the process…I can’t imagine its getting a JSON file as there is no path
AFAIK, register will grab the values available on that page identified in your call, save them as JSON, and then output them
But I am way out of my league on this one so take it with a grain of salt
Hmm maybe BobRay was right with his long-ago assumption that the proper value was simply 1
Here’s the relevant part of register.php, but I do not understand it:
class LoginRegisterProcessor extends LoginProcessor {
/** @var modUser $user */
public $user;
/** @var modUserProfile $profile */
public $profile;
/** @var array $userGroups */
public $userGroups = array();
public $persistParams = array();
public $live = true;
........
/**
* Setup persistent parameters to go through the request cycle
* @return array
*/
public function preparePersistentParameters() {
$this->persistParams = $this->controller->getProperty('persistParams','');
if (!empty($this->persistParams)) $this->persistParams = $this->modx->fromJSON($this->persistParams);
if (empty($this->persistParams) || !is_array($this->persistParams)) $this->persistParams = array();
return $this->persistParams;
}
*/this is the redirect
/**
* Check for a redirect if the user was successfully registered. If one found, redirect.
*
* @return boolean
*/
public function checkForRegisteredRedirect() {
/* if provided a redirect id, will redirect to that resource, with the
* GET params `username` and `email` for you to use */
$submittedResourceId = $this->controller->getProperty('submittedResourceId','');
if (!empty($submittedResourceId)) {
if ($this->controller->getProperty('redirectUnsetDefaultParams') == false) {
$persistParams = array_merge($this->persistParams,array(
'username' => $this->user->get('username'),
'fullname' => $this->profile->get('fullname'),
'email' => $this->profile->get('email'),
));
}
$url = $this->modx->makeUrl($submittedResourceId,'',$persistParams,'full');
if (!$this->login->inTestMode) {
$this->modx->sendRedirect($url);
}
return true;
}
return false;
}
I notice that the persistent data is also prepared for the activation email
So, according to what I can see, at least on your redirect page, if persistParams is set to 1, then you will have the username available as a GET param, as one of the array of values that persist
I was wrong if I said that. It’s definitely not a boolean. It takes a JSON object, like the example above, which is then passed to the ConfirmRegister snippet in the $_GET array. ConfirmRegister will then pass the array on to any URL that you have it forwarding to. There, they can be read by a custom snippet that pulls them from the $_GET array.
It seems like a long way around for something that might be more convenient as a $_SESSION variable.
It was a very old random comment from the old forum.
If I can read the code properly, the JSON seems to exist no matter what, as its used (I think automatically) to include the username and so on for use on the redirect page.
My none-too-careful reading suggests that the basic parameters like username, etc. are always passed as a JSON string, but &persistParams is for extra things you might want to send as well. I could be wrong.
Yes but how are those things *included in the JSON file I think is the question. However we should wait for OP to provide more direction.
Its also useful to remember that Register is a fairly old tool and isn’t really needed to do any heavy lifting other than its basic purpose. A 30 line custom snippet prior to the register snippet can easily do 10X more by preserving $_SESSION data
The &persistParams does take in a JSON object and does add them into the GET array my only problem now is trying to add in dynamic values from the form, something akin to Formit Retriever.
So after multiple different attempts with &persistParams, i gave up and used session variables in a prehook, since login.register starts one automatically.