Still on Drupal 7? Security support for Drupal 7 ended on 5 January 2025. Please visit our Drupal 7 End of Life resources page to review all of your options.
I am developing a custom Drupal module and I need to pass data dynamically from one module to another. For example, Module A generates some user-related data, and Module B needs to use it for custom processing.
Here’s a simplified scenario:
// Module A
function module_a_generate_data($uid) {
$user = \Drupal\user\Entity\User::load($uid);
return [
'username' => $user->getAccountName(),
'roles' => $user->getRoles(),
];
}
I am trying to create content by a script running outside Drupal. I know this is possible, and probably done better, using REST. But the script below is so simple to set up and works very fast that I'd like to try and get it to work in D10->, like it did in D7.
This code (from the final entry in this post), works to retrieve user and node data, running, for testing purposes, inside the Drupal root folder...
Hello all, i have a question regarding ajax forms. I have an ContentEntityForm, that creates a message and displays them on the page immediately. The textfield is cleared successfully, but not the file_field (for image or document uploads) after submit. How we can reset their value after submit?
I see that I can allow anonymous comments for all comments. But I do not see how to allow such comments on one entity type and not allow on other types.
For example I want to allow anonymous commenting on my 'Story' content but do not want to allow on my 'Recipe' content.
Please let me know how this should be achieved.
1. via admin UI
or
2. by extending/overriding some classes.
I am okay for any such ways.