Problems, need help? Have a tip or advice? Post it here.
14 posts Page 1 of 2
Hello KK,
I am using the extended users addon and so far everything is going on well except for some strange reason the k_user_access_level is same for all users: To get the k_user_access_level from all the users I did this:
Code: Select all
<cms:pages masterpage="users/index.php">
      <cms:show k_page_title /> // <cms:show k_user_access_level />
</cms:pages>


When I log in as super-admin all the k_user_access_levels change to the super-admin level(10) and when I log in as a normal user all the access levels change to 2. Why is it so? Any pointers? Thank you

What I seek to achieve is this:
1. I have related a messages.php template to the users template.
2. In a messages.php page, I am using <cms:related_pages > to bring the users into view so that I will be able to get the user levels and compare it to the currently logged in user and apply a class to it.
Looks like k_user_access_level is your global variable unaffected by <cms:pages>.
@adimpressions
Though you have marked the message to KK sir, still I will try to answer here. Hope it helps.
(@KK Sir, sorry to jump in, but then i just recently had a similar situation, so trying to explain)

Please see the following image:
userlevel.png
userlevel.png (6.56 KiB) Viewed 1600 times


As you can see in the image, under User Ids there are from values, viz.:
    EU = Extended User Id
    KEU = K Extended User Id
    UI = User Id
    PgId = Page Id

If you see, the values for KEU is same in all entries, i.e. 1. Similarly, UI is same in all entries, i.e. 4.
While the EU and PgId change for each entry.

Now when you are logged in the KEU and UI are set for the logged in user. KEU denotes the Id of the user that is assigned after the extended users module is applied. Whereas UI denoted the Id of the user that is assigned by default to the user by couch (the users visible in couch panel).

To access the above values:
Extended User Id:
Code: Select all
<cms:show extended_user_id />


K Extended User Id:
Code: Select all
<cms:show k_extended_user_id />


User Id:
Code: Select all
<cms:show k_user_id />


Page Id:
Code: Select all
<cms:show k_page_id />


Just enclose the above in
Code: Select all
<cms:pages masterpage=k_user_template>
...
   </cms:pages>

and you can see values for each user being set.

Btw, the page id is the id of the page that is generated out of the extended user template. The avove will help you understand why the k_user_access_level show the same value to all users and then changes according to the users logged in. It is a normal behavior of Couch.

Regards,
GenXCoders
Image
where innovation meets technology
Thanks guys I now understand how it works. I run into another issue on the same topic but a solution from trendoman helped me a lot. The solution is below in case someone else neds it.
Code: Select all
 <cms:php>
global $CTX; $user = new KUser( $CTX->get('extended_user_id'), 1); $CTX->set('extended_user_access_level', $user->access_level);
</cms:php>
<cms:set user_level="<cms:show extended_user_access_level />" scope='global' />


Another question:
I have a sign in form in the header section on the home page of my website. I want to know how to make users can use that form to sign in instead of redirecting them to another page with a sign in form. Hope you get me. Thank you
adimpressions wrote: Thanks guys I now understand how it works. I run into another issue on the same topic but a solution from trendoman helped me a lot. The solution is below in case someone else neds it.

I'll add the link to the original topic to save time searching viewtopic.php?f=4&t=11983#p32664
Another question:
I have a sign in form in the header section on the home page of my website. I want to know how to make users can use that form to sign in instead of redirecting them to another page with a sign in form. Hope you get me. Thank you


I suppose the login resides inside a menu or the navigation bar, etc.

Though I have not tested this, yet with the years of working with CouchCMS, I suppose this can be handled with:
Code: Select all
<cms:pages masterpage='users/login.php' limit='1'>
    <!-- Login form from the login.php goes here -->
    Code
    <!-- Login form from the login.php goes here -->
</cms:pages>


you will have to handle the redirect, upon login, explicitly. In case you need more clarification please share your code here.

Regards,
GenXCoders
Image
where innovation meets technology
Ok Genxcoders, let me try it out and give you feedback. Thanks for your immense assistance.
You are welcome.

Regards,
GenXCoders

P.S.: In case you are looking for even better assistance, I would request you to please buy a CouchCMS License. This will get you some timed yet great level support from the CouchCMS Creator (KK Sir) itself. And also help support CouchCMS development further.
Image
where innovation meets technology
Ok so I did this on the my website homepage:
Code: Select all
     <cms:pages masterpage='users/signin.php' limit='1'>
                <cms:form class="offset-by-six sign-in" method='post' anchor='0'>
           
                <cms:if k_success >
                    <cms:process_login />
                </cms:if>               
                    <cms:redirect url='clientarea.php' />
               
                <cms:if k_error>
                    <div class="alert-area">
                        <div class="alert alert-error">
                            <cms:each k_error >
                                <cms:show item /><br>
                            </cms:each>
                        </div>
                    </div>
                </cms:if>
                <label for="email">Email</label>
                <cms:input name='k_user_name' type="text" id="email" />
               
                <label for="password">Password</label>
                <cms:input name='k_user_pwd' type="password" id="password" />
               
                <input type="hidden" name="k_cookie_test" value="1" />
               
                <input type="submit" value="Sign In">
                <cms:if k_user_registration_template >
                    or <a href="<cms:link k_user_registration_template />">Sign up</a>
                </cms:if>
               
                <cms:if k_user_lost_password_template >
                <hr />
                <p><a href="<cms:link k_user_lost_password_template />" class="small-red">Forgot password?</a></p>
                </cms:if>               
            </cms:form>
                </cms:pages>


Now when I visit my homepage it automatically redirects to the signing page.
Edit #1: This is what makes your home page to redirect to the signin page. That needs to be handled explicitly according to your use cases as to which data you want to be displayed only if the user is logged in.

Edit #2: In case you were not signed in when you made the changes to the code then CouchCMS has not picked up the changes in the code. Make sure that you are already signed in as the Super Administrator before you refresh the code and allow CouchCMS to pick up the changes.

That is the default behavior.
This is because you are checking for the condition:
If user is logged in
// Show content
Else
// Redirect to the login page


Somewhere you have used the code:
Code: Select all
<cms:if k_logged_out>
    <cms:redirect ... />
</cms:if>


This is what makes your home page to redirect to the signin page.

Regards,
GenXCoders
Image
where innovation meets technology
14 posts Page 1 of 2