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
Related
I have wso2am4.0.0 and run success.
I want to change the textbox to drop down box of the Roles of basic info page (https://localhost:9443/publisher, Develop > Basic Info) , like image below.
How do I modify the source code of carbon-apimgt to make this change?
The publisher portal code can be found here - https://github.com/wso2/carbon-apimgt/tree/v9.0.174/features/apimgt/org.wso2.carbon.apimgt.publisher.feature
AFAIK, it's not possible. For that, you need to populate the existing roles list. Current publisher Rest API does not have such a resource to populate the role list and it only contains a validation resource[1].
[1] - https://apim.docs.wso2.com/en/latest/reference/product-apis/publisher-apis/publisher-v2/publisher-v2/#tag/Roles
On my website, The user can add the content and edit the content. On the edit page, there is one delete button to delete the content but I want to use that button to just hide/unpublish the content from the user and the public.
I have tried the below code but it is deleting the content.
function test_entity_predelete(Drupal\Core\Entity\EntityInterface $entity) {
$nid = $entity->id();
$node =Node::load($nid);
$node->setPublished(FALSE);
$node->save();
}
You can try to overwrite action button using hook_form_alter().
$form['actions']['delete']
Instead standard action use your own.
Firstly, do not allow users to delete nodes - by the proper
permissions settings.
Secondly add Publish/Unpublish button or just
show users Publish checkbox on edit form and instruct them how to
use it and how it works.
Maybe combination of modules can be helpful:
https://www.drupal.org/project/publishcontent
https://www.drupal.org/project/view_unpublished
https://www.drupal.org/project/override_node_options
I'm struggling to get a field to be enabled and/or visible based on user's role in Google App Maker.
I'm assigned to the Admins role and am trying to get the field to enable and/or visible if an Admin is the user of the page.
On the object i've added the below to the enabled and visible option
#user.roles ? "Admins"
but it's permenantly disabled. I've tried testing as both preview and published versions. I've also tried seeing it as #user.roles ? Admins and it still stays disabled.
Any ideas?
It should be (#user.roles).indexOf('Admins') > -1. Bracket placement seems to be very particular when using visibility or enabled when using a binding in app maker.
Try to set binding to:
(#user.roles).indexOf('Admins') > -1
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.