Problems, need help? Have a tip or advice? Post it here.
2 posts Page 1 of 1
Hello,

I was able to create custom fields to custom users using the "advanced users" addon.
One of them is a dropdown menu called "Extra role".

What I am wondering, is that with this addon, is it possible to set conditions based on is selected inside that dropdown menu?

Example :

Let's say I created a user name "John Doe".
In the advanced user creation page in the admin, let's say there's a "extra role" dropdown menu, and that I have selected "Salesman".

Is there a way to make a condition like this:

Code: Select all
<cms:if k_user_extra_role == "Salesman">
            #k_element_author{display:none;}
</cms:if>


I know "k_user_extra_role" doesn't exist, but you get the idea.
I would like to be able to hide content in the admin panel depending on the logged in user's "extra role".
Something that could be tied to the logged in user, globally, like "k_user_name" works.

With that in mind, I want to hide certain fields in some pages, and also only show entries that have been created by that logged in user, if his "extra role" is "Salesman".

Any idea how I can make this work?
Thanks
Hi,

So suppose the 'k_user_extra_role' was somehow available, your problem would have been solved.
Then it'd be easy to use something like this to hide fields -
Code: Select all
<cms:config_form_view>
    <cms:style>
        <cms:if k_user_extra_role == "Salesman">
            #k_element_author{display:none;}
        </cms:if>
    </cms:style>
</cms:config_form_view>

There could be several ways of adding that variable. One using raw PHP would be - viewtopic.php?f=8&t=11092 but I'd suggest you use the Couch tags way.

As explained in the docs on v2.0 viewtopic.php?f=5&t=10241, override the admin template that is used to display the fields in the form. That would be 'content_form.html'.

In the template, just above the <cms:form> block, use <cms:pages> with masterpage set to the extended-users template to find the current user and then set a global variable containing that user's role from the dropdown (you won't be able to set a variable beginning with the prefix 'k_' but that shouldn't be an issue).

Hope this helps.
2 posts Page 1 of 1