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.
Related
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!
I am trying to do the following in Drupal 7:
Users in my website will post ads and others will pay to get in touch with the author of the ad.
Users that are buying the contact information have to see all of the content of the ad(node), except for the author. After they pay, they should see an extra field in the ad, telling them who the author is.
My question is:
How can I control the user access per node and per user for a specific part of the node? Are there any modules for this?
Also, a relation between the user and the ad would be nice, since I will later have to list all ads for a user, etc..
I found many plugins, but they seem to deny or allow access to the entire node and my functionality should be different.
Thanks in advance
In order to allow only specific users or roles to view specific nodes, this module can help you:
https://www.drupal.org/project/nodeaccess
Also, as you want to restrict permission by field, the Field Permissions module can do the work for you:
https://www.drupal.org/project/field_permissions
Of course you might need to write some custom code or use Rules module to grant permission to the users who are going to be allowed to see some nodes/fields based on actions they do on your website.
I have a requirement of customizing user signup form in Drupal 7. i am not getting any relevant help from the internet . so i thought i should ask the expert here.
Requirement is i have two roles say "Student" and "Teacher". I have to use default user module for their signup by setting their roles automatically.
Now there will be two links one for Student signup another for Teacher Sign up. When user click on Student SignUp i am hiding some fields of default user module which are suppose to fill by a teacher, so student will see only fields, which are specified. Same for Teacher i am hiding fields which student suppose to fill.
So basically with the use of default user module i have to perform the sign up process.
Solution what i think could be possible :
I can set a variable in the link saying "studetnSignUp?status=student" and same for Teacher "studetnSignUp?status=teacher". Now the problem is i can do this in php but do not have proficient way to the same in drupal.
If it can be possible with any other approach please let me know. As it is really urgent for me. Your support will be really appreciated.
Thanks.
You can look into Profile2 in combination with Profile2 Registration Paths. It provides you with the ability to set a unique registration path for each Profile2 profile type. Per profile type you can define different fields. And I think a helpful feature is that it can assign user roles by registration path.
I would grab the passed parameter using menu and then call
hook_form_alter(&$form, $form_state, $form_id) {
if ($form_id == 'user_profile_form') {
// do your processing here
}
}
alter the layout of the form dependant of the user, and specify the users role in the form to, ie teacher or student
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.
In Drupal I wish to create a content type as a bio for a user. When you click on a a user name on the site it takes you to there bio. An example I have found online is below.
This article has the authors name Jeff Robbins. Jeff Robbins name links to his profile. How would you go about doing something similar? It does not seem be using the default profile module.
I would ideally only like this to happen for users in a certain group. For other users I wish just for there name to display but no link. Any pointers about how I would do this?
You've already got the core/programming route explained, so I thought I'd chime in with a few signposts on the install-a-module route. As always, with modules there is a bloated but supported solution and guidance on DIY.
Content Profile
Content Profile is a module specifically targeted at supported a User Biography as a node.
Here is an article describing how to add author biographies to nodes using Content Profile.
Author Pane
This module pulls information from the profile with an eye toward creating the sort of author information you would find to the left of a messageboard post.
Permissions
There are a couple modules that add finer control to the Profile permissions mechanism. There may be more, but these jumped out while I was looking for Content Profile.
Profile Role
Profile Permission
The node creator is stored in the node table (column UID), you could write something in a nodeapi hook to take that insert it as a field which can then be themed however you want. You could even in this hook put some logic to make the name a link or not depending on the roll.
You may want to look at the profile module, as this will allow you to set up a bio much more easily.
You can like Jeremy suggests do something like using hook_nodeapi(), but that seems like a bit overkill. I would instead use the template_preprocess_node() function. You could put this into a module or a theme. With it you can change the variable for $submitted, which holds the info for the author, date published etc. You can format it like you want, and keep the date and all that, and just instead make a different link on the user.
You could make it point anywhere really, so that the user is directed to a custom page that holds info on that user. It could a node on itself that you can setup with CCK ect, or you can use one of the profile modules that let your users customize their profiles, whatever works best for you.