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.
The module development and code questions forum is intended to aid those who are developing modules or writing code for Drupal.
Please note that this forum is also not intended for "Is there a module that does..." or "I need help with module x..." questions. It's also not a place to ask developers to write your code for you. Please respect this.
Please do not post general discussions intended to target module developers. If the question you have isn't specifically related to writing a drupal module, please post it in a more appropriate forum.
If you you have drupal installed already and are seeking a module that does a specific task, have a question about a specific module and what it does or if it will fit your use case, please place your questions in the Post installation forum.
If you have a problem or question about a specific module, you should create an issue in the module's issue queue (after checking for an existing issue first).
If you don't have drupal installed yet, please place your questions in the Before you start forum.
I have multilingual site. And there are content originally created in 'es' (Spanish) language. Now, we have to change all those existing content to 'en'. In my custom drush command, tried below thing but now working --
After loading the node object trying to change it like this --
I am developing a multi-vendor marketplace for a client in Iran and Afghanistan, where the official calendar is Jalali (Solar Hijri / Shamsi). I am using Drupal Commerce with the Commerce Marketplace module as the foundation.
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...