I want to hide superuser's (admin role) from the user's list.
Currently, any user can find a root user with the search. I also have a view "list of members" where root appears. I would like to find a solution ...
I tried the "User One" module but nothing changes. I work on Drupal 8.
Thanks,
Nemtecl
In drupal 8 all lists are views. So if you want to hide the user with the id 1, you have to edit the view and set a filter.
Go to URL/admin/structure/views and choose the correct view and click on edit.
Now add a filter criteria and choose "User Id" and set the filter to User id NOT equals 1
Just Create a view of users and in FILTER CRITERIA add a filter for (Roles User Roles that a user belongs to.) and add a Operator Is none of and select the role from Options.
Related
I've created a custom module and related it to vtiger organizations module. The custom module has an uitype10 attribute to link the record to the organization.
Everything works except that the organization name field in the quick create form of my related module is not automatically filled in. What I mean is:
if I go to organizations list, click an organization, click on Contacts icon and then click on the add button to add a new contact from the organization panel, the quick create form shows the organizazion name already filled in with the organization name I currently am in.
if I go to organizations list, click an organization, click on my custom module icon and then click on the add button to add a new record from the organization panel, the quick create form shows the organization name as empty. I have to manually write the organization name in it.
What I need is that my module behaves like the contacts module, so when I add a new record from the organization panel, the field for organization name should already filled in.
Any idea on how to achieve this?
Vtiger store Relation between 2 modules in vtiger_relatedlists table and based on details in this table Create Button URL will get generated in function getCreateViewUrl() in RelationListView.php. You can get core file in modules/Vtiger/models/RelationListView.php.
Solution : Table crestel_relatedlists will have relationfieldid which store the fieldid of your organization module against relation with your module. If relationfieldid is set to "0" then you have to set it with exact fieldid which you can get from vtiger_field table.
I need to display name, role, photo of current user.
I'm use views, in Advanced settings add Contextual filters select Content: Author uid and in settings of it select Provide default value ,in type selectbox choose User ID from logged in user.
But in fields i haven't field 'user:name'.
If i create relationship content : author , user name will be displayed, but only for users, that published node.
At the end, i want see like this
Hello, SmithJN
Role: Authorised user
Photo: [photo]
When you create the view, at the very first screen, you have the option to select the entity type on which you want to create the view. (thank J.Reynolds)
Then in Fields add Field Name, Role, Image In Fileter Criteria add filter User : current
It's all !
I want to notify the administrator when the user change his profile (for example, change his pseudo, his avatar and other custom fields attached to the user(People > Account settings > Add a new field) )
Thanks in advance !
I think the perfect module for this would be rules . There is a lot of docu on the project page.
Event:
Create a new rule on event user update
Condition
add condition (check for modifications..)
Result
trigger email
I need to change the menu links on my website (and leave the same items names) depending on the user is a guest, or authenticated user.
What's the standard way to do it ?
thanks
You cannot dynamically change a menu item's path, because menu items are cached.
Still, AFAIK, there are two ways to get what you want. Both methods require you to create your menu items with hook_menu in a custom module (not from the Menu UI).
The first method is to create two menu items with identical names and set the access rules so that one is only available for logged guests, the other for authenticated users. Since Drupal will only show menu items that the user is allowed to access, only one will show up at any given moment. In Drupal core, you can see how the user module creates a menu item for anonymous users by looking at the /user/login path in user_menu().
The second method is to create a single menu item and check in the menu callback if the user is logged in. If the user is logged in, you serve one page, if not you serve another. In Drupal core, the /user path works like this. See user_page to see how the code works.
You can dynamically change a menu item's path - see hook_translated_menu_link_alter.
This hook is called before every menu item is rendered IF it has the property ['options']['alter'] = TRUE.
You can set this property to menu items using hook_menu_link_alter.
Example code would be:
function MY_MODULE_menu_link_alter(&$item) {
$item['options']['alter'] = TRUE;
}
function MY_MODULE_translated_menu_link_alter(&$item, $map) {
if($item['mlid']==89) {
$item['link_path'] .= 'my-new-path';
}
}
Instead of altering the link, you coudl create the menues twice: once with the links for regular users and once with the links for registered/admin/... users
You can put a menu into a block and set it to only allow registered users to see the one block and non-registered users the other block. Either by selecting the proper radio button from the Drupal menu within the block creation form or via PHP that will evaluate and depending on it's return value (TRUE/FALSE) displays it. I suggest to go with the first approach.
You can change the menu by using a combination of nodeaccess module and linking to the corresponding pages.
For example, by default guest users cannot access /logout. If you create a link in a menu to logout, it will only display if a user is logged in. With nodeaccess, simply create a node, visit the grant tab and uncheck/check "authenticated users" or "anonymous users" for that node.
http://drupal.org/project/nodeaccess
Cheers,
A user might be in role X.
There exist a view, where display A is allowed for role X while display B is restricted.
How do i programmatically check whether a user belonging to role X can access the display or not?
What you should do, is to check the permission instead of the role using: user_access
Is there a specific reason why you want to do this programmatically? You can set access rules for Views displays in the Views UI:
Edit the view, select the display and look for "Access" in the "Basic settings" block. Click the value (default = "Untrestricted"), click the "Override" button to override the setting for that specific display and choose the settings you need.
Can be implemented inline in the theme, but better to break it up into module + theme. (assumes drupal-7) In your theme (node--contenttype.tpl.php) invoke a custom access method:
if (module_invoke('hottopicresearch', 'display_moderated_research_access_callback', 'update', $node)) {
Implement an this access callback in a module:
function hottopicsresearch_display_moderated_research_access_callback($permission, $node) {
And check roles
if (in_array("editorial board admin", $user->roles) || $user->uid == 1) {
and/or node access as noted in other answers:
if (!node_access($permission, $research_parent_node)) {
returning TRUE or FALSE.
This example gave access to people with 'editorial board admin' role and people who can write to the node. Nobody else can see the index. Of course this doesn't stop them accessing the node directly.