Login.Register parameter &persistParams

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


If anyone could lend some assistance i would appreciate it.

1 Like

Accoring to a random post by BobRay from years ago, the persistent params value will simply be ‘1’

Its unclear how this works but would seemly capture all parameters available on that page to JSON, then just unpack it on the redirect page. I think.

(possibly with &persistParams=1)


That will probably work, but it’s a good habit to put all property values in back-ticks:

1 Like

@nuan88 unpack the JSON from where?

Also if you put JSON in the parameter like :


the data shows up i the redirect page URL as a get parameter

1 Like

I’m gonna be honest here, I don’t think basically anyone here knows how this works :stuck_out_tongue:

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

1 Like
1 Like

Ok good! That’s a great idea

I really am out of my league with this but have you tried some variation of this?


ATM I can’t decide if it should be one bracket or two unfortunately. Seems to me this will grab the value from that page and as you say retain it

1 Like

are these supposed to be placeholders?

if they are then yes i have.

1 Like

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) {
            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.

1 Like

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

I believe the extra stuff is merged into the array before the JSON is created, so they’re just properties like everything else that’s sent.

1 Like

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.

1 Like

So after multiple different attempts with &persistParams, i gave up and used session variables in a prehook, since login.register starts one automatically.

1 Like

I think that’s an excellent solution.


That’s great, and any work you are willing to show would be helpful for others in the future.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.