Register: call to posthook not working?

Hello!

I’m trying to implement a front-end user management in MODX.
For this I’m using Login + Bob Ray’s ClassExtender to manage extra user data.

I’ve an issue with creating new users with Register.
When I try to call ExtUserRegisterPosthook as posthook:

[[!Register?
    &submitVar=`loginRegisterBtn`
    &activation=`0`
    &usergroupsField=`usrgrp`
    &validate=`nospam:blank,
  username:required:minLength=^6^,
  password:required:minLength=^6^,
  password_confirm:password_confirm=^password^,
  fullname:required,
  email:required:email`
    &submittedResourceId=`127`
    &useExtended=`0`
    &placeholderPrefix=`reg.`
    &postHooks=`ExtUserRegisterPosthook`
]]

<div class="register">
    <div class="registerMessage">[[!+reg.error.message]]</div>

    <form class="form" action="[[~[[*id]]]]" method="post">

        ...

        <div class="form-buttons">
            <input type="submit" name="loginRegisterBtn" value="Register" />
        </div>
    </form>
</div>

Submitting the form does create the user successfully, but does not trigger the posthook.

I’ve inserted some debug functionnalty in ExtUserRegisterPosthook, and I can confirm that the snippet is not called at all as posthook.

Maybe I made some mistake, so if anyone can help it would be great!

Versions:
MODX Revolution 2.8.3-pl
login-1.9.11-pl
classextender-2.2.0-pl

I don’t see why the posthook snippet wouldn’t be executed.

Does it work with a custom snippet with only this content?

<?php
$modx->log(modX::LOG_LEVEL_ERROR, 'post hook executed'); //Writes a message to the MODX error log
return true;

If the posthook is not executing, try moving it to the top of the properties list. If that fixes things, there’s something wrong with a property. Generally, properties below a problem property will be ignored (for example, using $propertyName instead of &propertyName).

In your validation property, I think this:
email:required:email

should be:

email:email:required

or more likely, just

email:required

Thanks to both of you!
I’m quite new to Revolution and didn’t think to check the error logs… Now I did and solved the issue.

It was linked to a query trying to insert a null value in a non null field on my extended user table.
For some reason the custom debug function I had put in the snippet initially didn’t work, so I was looking in the wrong way.

Thanks Bob,

I’ve just tested this forward and it seems that both usages are a bit different:

email:required

checks that email is completed

email:required:email 

checks that email is both completed + compliant to email format

Interesting. I’ve never seen that. It goes to show that you never stop learning new things about MODX.

My example email:email:required comes from the Register docs. I’m not sure what it would do.

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.