Forum for discussing general topics related to Couch.
14 posts Page 1 of 2
The current member login run like this:
1. user sign up
2. send user mail and user verify the account by click the link in mail
3. account activated

I like it to become like this:
1. User sign up and send a mail/message to site owner about verification.
2. The system does not send mail for verification. The account can only be approved by site owner manually for back-end system.

After user sign up, the system will send a mail to notify user that the account is being verified by the site owner and no verification link included in the mail, as it will manually approved by site owner.

3. After site owner approve the account, it will send a mail to user to notify that account is activated.

4. If the application is rejected or the account is deactivated, system should send mail to user too, to notify them they account is deactivated.

This member system will be apply quite a lot on my upcoming projects. Please provide me a solution if you can. Thanks.
Hi @nsy,

Apologies for the delay in my response - I seem to have lost track of this thread.

Could you please let me know if this question pertains to the 'members addon or the 'extended-users' addon?

Thanks.
no worries. as long as i get my answers, I can wait, I know you are a busy guy.

I think is member addon, i follow this post:
viewtopic.php?f=5&t=8063

By the way, what is 'extended-users' addon? maybe you can just provide me the post link, I take a quick look on it. Thanks.
By the way, what is 'extended-users' addon? maybe you can just provide me the post link
Sure. You'll find it here (under '1. Extended Entities') -
viewtopic.php?f=5&t=8581

I'll get back with the answer to your original query.

Thanks.
This is what I had on one site I did some time ago. The members functionality was dropped in the end, but I've left the original code on my computer.

Hope it helps!

Code: Select all
        <cms:member_check_login />

    <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">
            <cms:if success_msg='1' >
                Your account registration has been sent!<br> 
                You will receive an email once your account has been created.
           
            <cms:else />
                Activation was successful! You can now log in!<br />
                <a href="table-lamps.php#modal-login">Login</a>
            </cms:if>
        </div>
    <cms:else />
       
        <!-- now the real work -->
        <cms:set action="<cms:gpc 'act' method='get'/>" />
       
        <!-- is the visitor here by clicking the account-activation link we emailed? -->
        <cms:if action='activate' >
            <h1>Activate account</h1>
       
            <cms:member_process_activation />
           
            <cms:if k_success >
                 <cms:set_flash name='success_msg' value='2' />
                 <cms:redirect k_page_link />         
            <cms:else />
                <cms:show k_error />
            </cms:if>
       
        <cms:else />
       
            <!-- show the registration form -->

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

         
         
              // Here goes the registration form and error handling. Removed for brevity
             
               
            <input type="submit" name="submit" value="Create account" id="sign-up"/>
               
            </cms:form>
           
        </cms:if>
    </cms:if>   
Thanks, madebym. It's helpful but some of the features I requested are not included.

Maybe I just wait for KK....
@nsy I think that you have all the steps you want provided in my code snippet.

1. User sign up and send a mail/message to site owner about verification. CHECKED

2. The system does not send mail for verification. The account can only be approved by site owner manually for back-end system. CHECKED

After user sign up, the system will send a mail to notify user that the account is being verified by the site owner and no verification link included in the mail, as it will manually approved by site owner. CHECKED

3. After site owner approve the account, it will send a mail to user to notify that account is activated.
4. If the application is rejected or the account is deactivated, system should send mail to user too, to notify them they account is deactivated.

Points 3 and 4 have really nothing to do with Couch, it is all now in the site owner/admin hands. They must send the account activated email, the same for the last point.

Maybe I am missing something, please correct me if I do.
@nsy, @madebym
3. After site owner approve the account, it will send a mail to user to notify that account is activated.
4. If the application is rejected or the account is deactivated, system should send mail to user too, to notify them they account is deactivated.

Addressing the last two points was not possible previously but with the introduction of 'events' in the current version of Couch, we can finally now do it using some PHP.

Here is what needs to be done.
Please add the following code in couch/addons/kfunctions.php
Code: Select all
$FUNCS->add_event_listener( 'page_saved', 'my_save_handler', 10 );

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

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

    if( !$errors ){
        $field = $page->_fields['member_active']; // 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( 'activation_email.html' );
            }
            else{ // member deactivated
                $FUNCS->embed( 'deactivation_email.html' );
            }
        }
    }
}

The code above assumes your members template is named 'members/index.php'. Please modify it if that is not the case.

With that code in place, whenever you 'activate' or 'deactivate' a member account, Couch will execute snippets named 'activation_email.html' or 'deactivation_email.html' respectively.

You'll need to place those snippets in your installation's 'snippets' folder.
A sample implementation of 'activation_email.html' could be -
Code: Select all
<cms:send_mail from="<cms:show k_email_from />" to="<cms:show member_email />" subject='Access to Members Area Approved' debug='1'>
    Hello <cms:show k_page_title />,
    Your access to the members area of our site has been approved.
    Access the online resources using your email address and the password that you used to register.
</cms:send_mail>

Change the debug='1' to debug='0' once you are done testing.

Hope this helps. Do let me know.
Code: Select all
<cms:member_check_login />

    <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">
            <cms:if success_msg='1' >
                Your account registration has been sent!<br>
                You will receive an email once your account has been created.
           
            <cms:else />
                Activation was successful! You can now log in!<br />
                <a href="table-lamps.php#modal-login">Login</a>
            </cms:if>
        </div>
    <cms:else />
       
        <!-- now the real work -->
        <cms:set action="<cms:gpc 'act' method='get'/>" />
       
        <!-- is the visitor here by clicking the account-activation link we emailed? -->
        <cms:if action='activate' >
            <h1>Activate account</h1>
       
            <cms:member_process_activation />
           
            <cms:if k_success >
                 <cms:set_flash name='success_msg' value='2' />
                 <cms:redirect k_page_link />         
            <cms:else />
                <cms:show k_error />
            </cms:if>
       
        <cms:else />
       
            <!-- show the registration form -->

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

               
                <cms:if k_error >
                    <p class="notice"><font color='red'>
                    <cms:each k_error >
                        <cms:if item='<b>Name:</b> Page already exists by this name' >
                            <cms:set item='<b>Login Username:</b> Login Username already exists' />
                        </cms:if>
                        <cms:show item /><br />
                    </cms:each>
                    </font></p>
                </cms:if>
               
                <div class="member-form">
               
                    <p>* All fields must be filled in. *</p>
                               
                   <label>Your Name</label>
                    <cms:input name='member_displayname' Label='Your Name' type='text' required='1' /><br />
                   
                    <label>Login Username</label>
                    <cms:input name='member_name' Label='Login Username' type='text' required='1' /><br />
                   
                    <label>New Password</label>
                    <cms:input name='member_password' Label='Password' type='password'  required='1' /><br />
                   
                    <label>Repeat Password</label>
                    <cms:input name='member_password_repeat' Label='Repeat Password' type='password'  required='1' /><br />
                   
                    <label>Email</label>
                    <cms:input name='member_email' Label='Email' type='text' required='1' /><br />
                   
                    <label>Company Name</label>
                    <cms:input name='company_name' Label='Company Name' type='text' required='1' /><br />
                   

                    <button type="submit" name="submit" value="Create" class="submit">Create</button>
                    <button type="button" ONCLICK="window.location.href='../html/ourproducts.php'" value="Back" class="submit">Back</button>
            </div>
               
            </cms:form>
           
        </cms:if>
    </cms:if>


I tried this code, most of it did worked. But there are some part of the code is incorrect.

1. The mail that contain verification link still being sent. I need to remove the verification link in the mail as it will be manually activated by site owner.

2. As you can seen from code above, the username and login name cannot repeatedly created, it will prompt message to show that they are existed. Here is my problem, the system will send notification mail to site owner about the awaiting approval even though the registration process wasn't passed.

ex:

first user:
name: nsy
username: nsy
password: 123456
company name: test

second user:
name: nsy
username: nsy
password: 789012
company name: bbbb

The first user already takes the name of nsy, it already in the system. And the second user attempt to use the same name, nsy, the system prompt message about this name already existed. Once the second user clicked on submit, the system will sent notification to the site owner about approval before the second user do any edit on name. The register procedure is not complete, yet system already sent out old info.

The site owner keep receiving the same mail if I keep pressing on the submit button even though the system prompted the message of existed input field. For example:

second user:
name: nsy
username: nsy
password: 789012
company name: bbbb

If I press submit 10 times on same data above, the message prompted about existed input field and user need to change it, the registration process is not complete, yet the site owner will receive 10 of this notification about same data.
Hi, KK,

I have another problem with this section. I got 2 hosting companies that handle all my website projects, one of my hosting company require me to do SMTP authentication or I will failed receive mail, what should I do to integrate this to your code?

sample code:

Code: Select all
equire("PHPMailerAutoload.php");

$mail = new PHPMailer();

$mail->IsSMTP(); // send via SMTP
$mail->Host = "abcd.com"; // SMTP servers change to localhost
$mail->Smtp_port ="2525";       // change smtp port
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "noreply@abcd.com"; // SMTP username
$mail->Password = "password"; // SMTP password

$mail->From = "noreply@abcd.com";
$mail->FromName = "abcd";
$mail->AddAddress("$your_email","$your_name");
$mail->AddReplyTo("abcd@gmail.com","abcd");
$mail->addBCC("abcd@gmail.com");


or you may just refer this link: http://www.ipserverone.info/programming ... hp-mailer/

or maybe you got another solution that already existed in your current CMS?
14 posts Page 1 of 2