Drupal 7 fields - only editable by specific roles - how? - php

I have some fields that my users cannot be allowed to edit - however, certain roles would need permission to do so. There are also other fields that the user may edit.
How would I do this? I tried looking in roles.
I did see this question: Drupal, user profiles: adding fields *only* editable by administrators
but couldnt figure out how to make sure that the fields are never editable by regular users, and also how to make sure only specific roles can edit.
I'm fairly good with php, but i can't seem to find my way around on the drupal site.
/Anders

have you tried using Field Permissions module.

Related

How can I build "user group" access control into WordPress?

WordPress has some lovely features for storing revisions, editor approval of content, etc.
I'd like to expand on them by creating the concept of a user group/organisation.
I want:
to be able to attach posts to an organisation
to be able to attach users to an organisation (and ideally make it so that users can invite other users to their same org)
users can only make changes to posts in the same org as them, everything else is read only.
I can do the first two with a custom post type and an Advanced Custom Fields post object field, but I'm stumbling on the last one and would appreciate some pointers.
I imagine I would need to create a custom role with add_role(), but I'm not sure what capabilities it should have.
I imagine I'll need to override a hook somewhere to check if the thing the user is trying to edit is in their org.
Only relevant code so far is:
register_post_type("organisation");
First, on WordPress, the default user system is: admin can do everything, editors can edit every post, authors can only edit their posts.
There are some plugins like https://es.wordpress.org/plugins/user-role-editor/ that may be useful for your needs. Have a look at that!

Can't edit all the fields in an item inside a Contao module

I am having some problems with our business website that is managed with Contao.
I want to edit some fields of something, that doesn't appear on the regular edit button. To make it clear, this is what I see on the edit page:
And this is what I see are the module details, there is a bunch of stuff that I want to change there, but can't from the actual edit page. Any way to access these options?
If I haven't made myself fully clear, please ask away.
Contao has a detailed role configuration where every field for specific users or roles can be set. If you can't see all of the fields, it's because your user has probably not the rights to edit this fields.
You should ask the person with Contao Administration privileges if he can grant more privileges for your user or user-role.
Not all the fields you can see in the details popup are used bei you module.
Your module type is "Course", which seems not to be from the core. So this module is from an extension.
The pallet defined in the course module is defined, to show you the fields you see, because it doesn't need more, to be configured.
Maybe aksing the maintainer of the extension, how to configure this module, is an idea.

drupal 7 show/hide field for a role

is there a module to show/hide fields to a specific role in Drupal 7?
I know Field Permissions Module, but it is not exactly what I need.
I have two fields:
picture
picture_premium
and these roles:
anonymous
authenticated
premium
the picture field should be visible for: anonymous and authenticated
the picture_premium field shoudl be visible for: premium
note that premium should not see the picture field.
You should use Field Permissions module.
It's built just for that.
Hope that helps... Muhammad.
To expand on that a bit - in the scenario as described, Field Permissions would not work, as all premium users would also be authenticated. The only way you could use Field Permissions to do this is by assigning a separate role like "regular" to all non-premium authenticated users. Then you could make the picture field visible to anonymous and regular, and picture_premium to premium.
I don't know yet if there is a better solution.

Symfony 1.3: Need to override backend filter field's set of data

My project is using Symfony 1.3.11, PHP version is 5.3.3.
Let me explain my case and my problem:
We wanted to add another kind of user, not just "user" and "admin" (using sfGuardPlugin). I did add "business" and I did give him permissions to only ONE admin module -- "purchases" (accessing own and under some conditions -- other people's purchases made on the site).
The "business" user can be associated to one or more Partners (firms) registered in the site, effectively allowing us to handle business owners or representatives a wee bit differently.
When the "business" user accesses the admin section, the list of purchases he sees must be this: All Purchases for all Products of all Partners he has associated with him. (Not exactly a trivial query).
I did that, in my opinion, in a stupid manner, but it does work -- namely overriding the "apps/backend/modules/purchase/actions/actions.class.php#executeIndex". I had to first copy-paste some code from the version of that method in the cache.
In short, I did hook myself to the "executeIndex" and added a code to do the proper Criteria, and the code works.
The problem now is this:
The filter field above the list (the one containing the Product list) does contain all possible Products. We want it to only contain all Products for all Partners the current user is associated with.
Thing is, it's my first time having to override the admin's filters and I am lost as to where should I plug my code.
Any help is appreciated. Thanks for your time.
UPDATE: Strangely very unpopular question. Nobody ever had to do this? Wow.
You have to unset the product_list and set another widget with the filtered choices.
Check this post where I explain something like that but using doctrine. In your case the sfGuardUserForm is your somthingFilterForm.
You could also filter data using this method. This is a little more elegant but both would work.

One-To-Many member-to-articles relationship

We are new to Expression Engine and could maybe use some help from anyone who has built a few sites using this CMS.
We have a small dashboard system where users log in and read articles that are submitted from other authors. We are wanting to have a form which allows a member to chose which categories of articles he would like to be on his home page when he logs in. Then we'd like to figure out how to actually create that home page so that only the categories of articles that the user has chosen are visible.
From a DB standpoint this seems to be a one to many relationship between a member and categories, but we don't have a clear idea how to accomplish this inside of EE (without raw PHP/queries), especially using the Member module, since it isn't a channel and doesn't seem to allow creating relationships in the member custom fields.
We looked at creating a custom field for every category type, but there are about 95, and as we add or remove them, it would be extremely cumbersome to try to keep up with them all. Even if we did we still aren't sure how to connect 1 member to many categories or many entries via a category.
We'll update the question later to add some of the code we (if any) that we've come up with
In short, there isn't going to be a built in way to handle this. That isn't to say however that this can't be handled with some modules that are already out there. Let me ask you this. When you have users logging in, are they logging in to Expression Engine itself's backend, or the login system that you have created on a public facing website.

Categories