Problems, need help? Have a tip or advice? Post it here.
6 posts Page 1 of 1
I have downloaded the users.zip package that has 5 example templates that can be used.I have users/index.php and users/register.php successfully showing in my admin panel......Ive been reading up on databound forms and couch form tags and I understand the concept but

1.How do I hook the profile.php template to this?
2.Also when someone logs in is it possible to have their username displayed in the top instead of saying login?
3.How to set it up for logout?
4.I also wonder if i have everything right...I have the 4 templates configured and styled-I can register and login but once logged in I cant tell Im logged in by any means unless i go to the admin panel under administrator and logout..maybe the profile template does more?
5.Ive tested what I have so far and if I try to login anyone besides an administrator it says access denied.....Im lost on gow to put this together.....Inoticed the tags that I think go on template pages from researching the old member module so I tried those and dont know if I m doing it right
Ive managed to set up and style 4 of the 5 templates using extended users....However I dont understand how to use profile.php template or how it hooks in or where...Ive read the documentation but it doesnt give detail over this template....I notice when i login a created user that nothing really seems different-I dont see the username in the top bar or anything such as that....Is it possible that when someone logs in that it shows their username on the website? is it the profile template that does this?
The profile.php template is just a place for a user to view and update their profile information. You can place a link to profile.php on the page somewhere for someone to access it.

For myself, I don't have a separate profile.php template. Instead, a snippet of code is available on every page for managing user profiles. It is hidden and shown using javascript.

The important idea I'd like to get across is that the many templates and tutorials Couch provides in the documents and on the forum are meant only as a starting point. Once you understand how they work, you can go on to make what you want from the tools available.

You'll want to learn more about using Couch variables. They're very useful for creating powerful dynamic content. http://www.couchcms.com/docs/concepts/variables.html

You should also learn to use the cms:dump and cms:dump_all tags. You can place them in your code to show you what variables are available to you. I've gone so far as to put a cms:dump_all tag at the bottom of every page when logged in as super-admin. This gives me a quick reference and helps me to understand what's happening on a page when I'm developing and troubleshooting.
Code: Select all
<cms:if k_user_access_level ge '10' ><cms:dump_all/></cms:if>

Now for your specific question, to show the username and a logout link on a page, use the following snippet. Notice how it's simply using Couch system variables to show the information.
Code: Select all
Welcome, <a href="<cms:link masterpage='users/profile.php'/>"><cms:show k_user_title /></a> | <a href="<cms:show k_logout_link />">Logout</a>
The code above links pages to the user profile, but it's not complete. The links are shown on the page whether the user is logged in or not. To fix it we'll use the cms:if tag with more system variables.
Code: Select all
<cms:if k_logged_in >
    Welcome, <a href="<cms:link masterpage='users/profile.php'/>"><cms:show k_user_title /></a> | <a href="<cms:show k_logout_link />">Logout</a>
</cms:if>

In your case, if someone's not logged in you probably want to prompt them to sign up or log in.
Code: Select all
<cms:if k_logged_in >
    Welcome, <a href="<cms:link masterpage='users/profile.php'/>"><cms:show k_user_title /></a> | <a href="<cms:show k_logout_link />">Logout</a>
<cms:else/>
    Not a member? <a href="<cms:link masterpage='users/register.php'/>">Sign Up</a> | Already a member? <a href="<cms:show k_login_link/>"> Sign In</a>
</cms:if>
Thank you Tim .I couldnt understand how to link the profile template but makes sense now and I understand how to style the particular template....Ive noticed that under my admin panel that the users and register templates have lines through them under super admin-and under the admins panel these folders arent even seen...Is there a way to have them seen under the admins?? and is it normal for the lines to be through these folders under super admin?
1-My ultimate goal here is to create an controlled access website where the client wants people to register but be limited to a few pages unless they pay....However she doesnt want paypal involved just them sending their credit card info by form and once she approves payment to be able to remove their restriction and give them full access.
Ive never does this before.
The strikethrough means that the template is hidden in the admin panel. You can add hidden='1' to the template tag when it's unnecessary for admins to work with a template on the backend. This is a good way to reduce clutter in the admin panel. Another useful parameter is order="(a number)" to arrange the templates in the sidebar. Otherwise they show up in the order you created them.

User Access (http://www.couchcms.com/docs/concepts/users.html)
Now that you've got your users module set up, you can start controlling access to different parts of the site. You do that with if statements.

The snippet above said "if the user is logged in show these links, otherwise show these other links" by evaluating the variable k_logged_in. This applies to all access levels from super admin on down - anyone who's logged in.

You can also use k_user_access_level in the conditional. <cms:if k_user_access_level ge '10'> would apply only to super admin. <cms:if k_user_access_level ge '7'> would be admin and above.

So you can use the user's login and access level to decide who sees what. Wrap a certain section of code in if tags to determine who sees it.
Code: Select all
<cms:if k_user_access_level ge '4'>
    <p>This is the good stuff.</p>
<cms:else/>
   <p>You must be a paid subscriber to see this content. <a href="payment.php">Join Now</a></p>
</cms:if>

Or restrict the entire page, either with if tags or from the advanced settings in the admin panel. If you use the admin panel, they'll just get a system notice that they don't have access. If you use if tags, then you can show a "Join Now" prompt instead of the page.

The extended users module automatically makes users level 2: Authenticated Users. So all you have to do is bump paid users up to 4: Special. How you do that could be tricky. Ideally, you would do it programmatically, so as soon as someone pays they gain access. That would involve setting up a listener to change the access level when PayPal's IPN or whatever payment gateway pings you that payment has been received. You could surf the forum for ideas, or maybe someone else will jump in to help.

The crude and easy way would be for the admin to change that user's access level in the admin panel when she receives payment. And this sounds like what she wants anyway.

P.S. Be super careful about security if you really plan to send credit card info using a form. This sounds like a bad idea security-wise. Let a payment gateway handle that instead.
6 posts Page 1 of 1