Important announcements from CouchCMS team
148 posts Page 1 of 15
Previous 1, 2, 3, 4, 5 ... 15 Next
This addon has been superseded by extended users functionality.

Hi everybody :)

The long awaited members module is finally here.

If you have been following Couch's development in recent times, you must have certainly realized that with the advent of features like 'relations' , 'front-end submissions' and 'custom admin screens', Couch is slowly getting to the point where we can use it to create pretty complex 'vertical' applications e.g. a full-fledged e-commerce solution or even forums.

However, the one missing feature that had always prevented this from happening was a proper user-login/registration module.
While this was always on the cards, @cheesypoof simply went ahead and created a full-blown module (, amazingly using Couch tags alone!

The beauty of this implementation was that it used a regular Couch template for creating user-accounts.
As each user-account is basically only a regular cloned-page, this approach places the full gamut of Couch's existing features at its disposal.
For example -
a. We can define any number/type of editable regions (i.e. custom fields) to hold user-data. So if your site decides to follow Facebook in allowing users to idenfify themselves using 51 gender types - no sweat :)

b. We can use the 'relationship' feature to relate 'users' with other cloned pages e.g. posts, likes, videos, etc.

c. We can use the full power of cms:pages tag to list users slicing and dicing through the custom fields.

The members module being released here is an adaptation of @cheesypoof's implementation. I've only abstracted away the complexities of the various functions by exposing them as regular Couch tags.
This should make it a breeze for anyone to implement a full-fledged user login/registration using their own designs.

1. Download the attached zip and extract its contents.
Copy the 'couch/addons/member' folder to the corresponding location of your installation and
add the following line to 'couch/addons/kfunctions.php' file (you might have to rename kfunctions.example.php to kfunctions.php)
Code: Select all
require_once( K_COUCH_DIR.'addons/member/member.php' ); 

2. Place the 'members' folder in your site's root and register all the 5 templates within it (i.e. visit the templates using your browser while being logged-in as super-admin e.g. type in your browser's address bar to execute and thus register the 'members/index.php' template)

The templates found in the 'members' folder are only meant to show a sample implementation of all functions provided by this module. As such, they use only bare-essential markup. You are expected to use your own markup once you understand how things work.

The names and locations of these templates are configurable from the 'addons/member/config.php' file but while playing around with the module for the first time it is recommended you go with the current settings.

The 'members/index.php' template is the core template (where every cloned page of this template will represent a user-account).
Please notice the cms:member_define_fields tag in it - it creates all the required fields.
Of course, you are free to add any number and types of editable regions to this template.

As mentioned, this module exposes all typical user-login/registration functions as regular Couch tags.
So what are these 'typical' functions?

Broadly speaking, there are six such functions that you are likely to find in any user-login implementation you'd find out there.
I like to group them in pairs, so we have -
Forgot/Reset password
Register/Activate account

This addon exposes each of these functions as a separate tag -
Login - cms:member_process_login_form
Logout - cms:member_process_logout
ForgotPassword - cms:member_process_forgot_password_form
Reset password - cms:member_process_reset_password
Registration - cms:member_process_registration_form
Activate account - cms:member_process_activation

The tags, of course, are meant to be placed within Couch templates.
If one so wishes, all the six tags can be placed on a single template.
However, for sanity's sake, it is logical to delegate each of the three above-mentioned 'pairs' to a separate template each.
This is how we structured the sample implementation -
Login/Logout - members/login.php
ForgotPassword/Reset password - members/lost-password.php
Registration/Activate account - members/register.php

('Edit profile' function (members/profile.php) is not a login/registration related function, as far as we are concerned - we can code that us using front-end forms.)

Please take a look at the templates to see how the tags are used.
If you are conversant with how forms work in Couch, you'll find the code pretty straightforward.
Following are a few points that merit your attention, though -

1. In all the templates of your site that need access-protection, we place the following code at the
top of the template -
Code: Select all
<cms:member_check_login />

Depending on whether or not a user is logged-in, this tag sets some variables that can be used further down in the template e.g.
Code: Select all
<cms:if k_member_logged_out >
    <cms:redirect "<cms:member_login_link />" />

Essentially, except for 'members/index.php', ALL the other templates make use of <cms:member_check_login /> like ordinary templates of the site.

To add a 'logout' link for the logged-in user, use the following code
Code: Select all
<a href="<cms:member_logout_link />">logout</a>

2. Of the six tags, the following three tags are supposed to be used only within a form's success condition (the rest use querystring parameter)-

3. Each of the three above-mentioned tags expect some input fields with well-defined names in the forms. I've documented those in the templates.

4. Some of the tags (e.g. cms:member_process_reset_password etc.), as part of their function, send emails to users.
The elements of the emails can be changed through the module's config file.
However, if you wish to prevent these tags from automatically sending the emails so that you could do it using your own code, set the 'send_mail' parameter to '0' (with cms:member_process_registration_form this parameter is '_send_mail' to avoid possible clash with custom fields). for example -
Code: Select all
<cms:if k_success >
    <cms:send_mail ...
    <cms:set_flash name='success_msg' value='1' />
    <cms:redirect k_page_link />

5. Finally, the cms:member_process_registration_form deserves sone extra attention -
a. As you know, all cloned pages expect the k_page_name field to have a unique value.
With member accounts, the email is also unique. So we basically end up with two unique ids.
This is usually redundant and we can make do with only the email (except perhaps in applications like 'forums' where the name also has to be uniquely identifiable).
The way this tag works, if we do not use an input field named 'member_name' in the registration form, cms:member_process_registration_form automatically creates a random k_page_name.

b. This tag works much like a databound-from (please see ... forms.html) so it can accept explicit field_names as parameters.
So, for example, if the registration form has an input field named 'dob' that is to persisted in an editable region named 'dob' of the index template, the code would become
Code: Select all

c. Using the registration form without spam protection is a sure way to invite a deluge of bogus user accounts. Please do make sure to use the protective measures discussed at ... 047&p=9255

Hope this helps.
As always, your feedback is solicited :)


Great news KK! I was waiting for this for some time. Now Couch CMS tends to be a complete solution for web designers. It still misses some basic features like customer management, order management on the cart part, but with each passing day it's getting closer to a full featured CMS solution. Congratulations!
I try to understand how to use this ...

Can you place this in any template of your site folder:

Code: Select all

<cms:member_check_login />

<cms:if k_member_logged_in >

    <p>Logged in</p>

<cms:else />

    <p>Not logged in</p>


Or should this be inside a template of the members folder ?
I load frameworks and write bugs on top of them, after that I rearrange the code so that it looks like a cool product.
@atisz, Thanks :) With the members module in place, we'll have a proper order+customer management with CouchCart soon.

@Tomarnst - you have it right. You can place that code on any template of your site where you wish to check for a logged-in user.

What you do after knowing if the user is logged-in or not is totally upto you. For example the following code will simply redirect the user to the login page -
Code: Select all
<cms:member_check_login />

<cms:if k_member_logged_out >
     <cms:redirect "<cms:member_login_link />" />

As an example, following could be a template (skeletal outline) that has content accessible to only logged-in users -
Code: Select all
<?php require_once( 'couch/cms.php' ); ?>

    <!-- check the login status of the visitor -->
    <cms:member_check_login />

    <!-- if not logged-in, redirect her to the login page -->
    <cms:if k_member_logged_out >
         <cms:redirect "<cms:member_login_link />" />

    <!-- if a visitor is able to reach this point, he is definitely logged-in -->
    <!-- code the usual stuff here. This will only be available to logged-in user -->
    <!-- also give an option to logout -->
    <a href="<cms:member_logout_link />">logout</a>

<?php COUCH::invoke(); ?>

Hope this clears up the doubt.
That's it, gotta finally subscribe. Missed by week.
Thanks for kind reminder, KK. I will checkout and add to my module list.

Don't have time to go through at the moment, but will definitely try and play around with this.
Will give feedback of course.

I only hope the e-mail UTF-8 fixes are included! :D

Thanks for great work, KK and cheesypoof!

Ah, another question. How easy it is to work with existing API's? I haven't done much, but nowadays, single-click registration is a must. How difficult (estimated) should it be to get it together with facebook?!
How difficult (estimated) should it be to get it together with facebook?!
We did develop a simple 'social login' addon in tandem with this module (for now, it consists of only Facebook login).

Decided against including it with this members module, though, as the members module is slated to ship as a core component of coming versions.

If you'd like to try it out, let us know and we'll release it here.
I'm loving this members module, wondering why you didn't add it below USERS in the backend.
I'm trying to integrate this module into the comment system but k_comment_author doesn't recognize k_member, only k_user. Is there a way around this?

Additionally I added a few new fields plus an image field to my members template, how can I set Couch to recognize this field as k_member_avatar?

Lastly if you could make the backend for the members template, display how many comments a particular member has posted on the site... and how many votes.
You live many times, but only ever remember your lives.length - 1
Would there be a way to forego the activation link being sent to the email? I would like to require an admin to activate members manually.


EDIT: Oops, just read the original post more closely. Thanks!

Is it possible to get the inline edit working for members on some specific editable fields ?

Something like :

<cms:if k_member_logged_in >
<cms:load_edit />

Some editable fields here..

I load frameworks and write bugs on top of them, after that I rearrange the code so that it looks like a cool product.

The 'inline editing' feature is meant only for the site-owners (super-admins and admins).
While the 'members' feature only creates ordinary users (i.e. not admins).
Therefore, we cannot combine the two to use them together.
Previous 1, 2, 3, 4, 5 ... 15 Next
148 posts Page 1 of 15

Who is online

In total there is 1 user online :: 0 registered, 0 hidden and 1 guest
(based on users active over the past 5 minutes)

Users browsing this forum: No registered users and 1 guest