Forum for discussing general topics related to Couch.
14 posts Page 2 of 2
@nsy,

I have made the necessary amendments to @madebym's code.
The following version should work the way you want it to -
Code: Select all
<?php require_once( '../couch/cms.php' ); ?>
    <cms:template title='Registration' hidden='1' />

    <cms:if k_member_logged_in >
        <!-- what is an already logged-in member doing on this page? Send back to homepage. -->
        <cms:redirect k_site_link />
    </cms:if>
   
    <!-- are there any success messages to show from previous actions? -->
    <cms:set success_msg="<cms:get_flash 'success_msg' />" />
    <cms:if success_msg >
        <div class="notice">
            Your account registration info has been received!<br>
            You will receive an email once your account has been created.
        </div>
    <cms:else />
       
        <!-- show the registration form -->
        <h1>Create an account</h1>

        <cms:form enctype="multipart/form-data" method='post' anchor='0'>
            <cms:if k_success >
                <!--
                    The 'member_process_registration_form' tag below expects fields named
                    'member_displayname', 'member_name' (optional), 'member_email',
                    'member_password' and 'member_password_repeat'
                -->
               
                <cms:set submitted_values=k_success />
               
                <cms:member_process_registration_form
                    _send_mail='0'
                />
               
                <cms:if k_success >
                    <cms:send_mail from=k_email_from to=k_email_to subject='New account registration' debug='1'>
                        The following is an email sent by a user who registered for an account on xyz.com:
                        <cms:show submitted_values />
                    </cms:send_mail>
               
                    <cms:set_flash name='success_msg' value='1' />
                    <cms:redirect k_page_link />
                </cms:if>
            </cms:if>

            <cms:if k_error >
                <font color='red'><cms:each k_error ><cms:show item /><br /></cms:each></font>
            </cms:if>
           
           
            Screen Name:<br />
            <cms:input name='member_displayname' type='text' /><br />
           
            Email Address:<br />
            <cms:input name='member_email' type='text' /><br />
               
            Password:<br />
            <cms:input name='member_password' type='password' /><br />
           
            Repeat Password:<br />
            <cms:input name='member_password_repeat' type='password' /><br />
               
           
            <input type="submit" name="submit" value="Create account"/>
           
        </cms:form>
           
    </cms:if>   
<?php COUCH::invoke(); ?>

Please test it and let me know.

Regarding your other question on SMTP mailer - please see viewtopic.php?f=8&t=8720

Hope it helps.
I am trying to use this feature with the extended users addon. I've changed the code to this but it's not working, any ideas?

Code: Select all
//E-mail sturen bij activatie en deactivatie account
$FUNCS->add_event_listener( 'page_saved', 'my_save_handler', 10 );

function my_save_handler( &$page, &$errors ){
    global $FUNCS;

    if( $page->tpl_name != 'users' ) return; // not the template we are interested in. Return quick!

    if( !$errors ){
        $field = $page->_fields['disabled']; // the field we are interested in
        if( $field->page_id != -1 && $field->modified ){ // if not a 'new' page and field modified
            if( $field->data==1 ){ // member activated
                $FUNCS->embed( 'elements/activation_email.html' );
            }
            else{ // member deactivated
                $FUNCS->embed( 'elements/deactivation_email.html' );
            }
        }
    }
}
I think the problem lies here -
if( $page->tpl_name != 'users' ) return; // not the template we are interested in. Return quick!

Name of any Couch template will definitely have the '.php' extension.

Please use the name of the template you specified within couch/addons/extended/config.php e.g.'users/index.php' as in the following configuration -
// Names of the required templates
$t['users_tpl'] = 'users/index.php';
$t['login_tpl'] = '';
$t['lost_password_tpl'] = '';
$t['registration_tpl'] = '';

Hope this helps.
Thanks for your quick response KK!

I've tried to change "users" to my users/index.php template. However, this didn't work either. I had then changed it to "users" thinking the "deactivate" checkbox is present only in the users panel of the backend and not the users/index.php.
14 posts Page 2 of 2