We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38878
    • 255 Posts
    I am running Revo 2.2.6, Login 1.8.1 and GroupELetters 1.0.

    I am attempting to included the GroupELetters subscription functionality to my Registration form calling the GroupELetterSingup snippet as a posthook hoping that it would behave for Register as a true posthook in hopes of not interfering with the registration code that was functioning fine. What is happening is that the GroupELetters subscription is working but the user is not being registered. This makes no sense by the definition of a posthook which is supposed to be called after the registration snippet completes. Both the prehook recaptcha and the form validation are working fine, but the registration is not submitted.

    The registration snippet call looks like this:
    [[!Register? 
    &preHooks=`recaptcha`
    &postHooks=`GroupELetterSignUp` 
    &submitVar=`registerbtn` 
    &activationResourceId=`20` 
    &activationEmailTpl=`activationEmailTpl` 
    &activationEmailSubject=`HCEV Registration Confirmation!` 
    &submittedResourceId=`21` 
    &usergroups=`Members` 
    &validate=`nospam:blank, username:required:minLength=^8^, password:required:minLength=^6^, password_confirm:password_confirm=^password^, fullname:required, email:required:email, first_name:required, last_name:required, terms_accepted:required:true`
    &placeholderPrefix=`reg.` 
    ]]


    And the GroupELetterSignup snippet code is:
    <?php
    /**
     * Signup hook for FormIt
     * This is a post hook 
     * 
     */
    if (!isset($modx->groupEletters)) {
        $modx->addPackage('groupeletters', $modx->getOption('core_path').'components/groupeletters/model/');
        $modx->groupEletters = $modx->getService('groupeletter', 'GroupEletters', $modx->getOption('core_path').'components/groupeletters/model/groupeletters/');
    }
    $groupEletters =& $modx->groupEletters;
    
    $confirmPageID = $modx->getOption('confirmPage', $scriptProperties, $modx->getOption('confirmPageID') );
    // FormIt options:
    //'emailFromName' => $modx->getOption('emailFromName', (isset($scriptProperties['emailFromName']) && !empty($scriptProperties['emailFromName']) ? $scriptProperties : NULL ), $modx->getOption('groupeletters.fromName') ),
    $options = array(
            'emailTpl' => $modx->getOption('emailTpl', $scriptProperties, 'GroupEletterSignupMail' ),
            'emailSubject' => $modx->getOption('emailSubject', $scriptProperties, $modx->lexicon('groupeletters.subscribers.confirm.subject') ),
            'emailFrom' => $modx->getOption('groupeletters.fromEmail'), //$modx->getOption('emailFrom', $scriptProperties, $modx->getOption('groupeletters.fromEmail') ),
            'emailFromName' => $modx->getOption('emailFromName', $scriptProperties, $modx->getOption('groupeletters.fromName') ),
            'emailReplyTo' => $modx->getOption('emailReplyTo', $scriptProperties, $modx->getOption('groupeletters.replyEmail') ),
        ); 
    // $hook->setValue('datestamp_submitted', $datestamp);
    // 
    
    if( $groupEletters->signup($hook->getValues(), $confirmPageID, $options) ) {
        return true;
    } else {
        //$scriptProperties['hook']->errors['signup'] = $groupEletters->errormsg;
        
        $hook->addError('signup', $groupEletters->errormsg );
        return false;
    }


    Upon registration, the GroupELetter signup confirmation page is shown and I have verified that the subscription is processed which would be fine if the user was created which it is not. I doubt that the Formit options are the problem since the subscription would fail if it was an issue.

    Am I missing something obvious? Or what suggestions does anyone have. Unfortunately toe posthook examples in RTFM on Login are a bit sparse and I have found nothing in my googlings even close so I am at a loss.

    TIA for any ideas.