Full error message:

Error: Call to undefined function user_load() in CRM_Utils_System_DrupalBase->getUserObject() (line 558 of /var/www/drupal/vendor/civicrm/civicrm-core/CRM/Utils/System/DrupalBase.php)

I get this when using an api3 call like this:

$result = civicrm_api3('User', 'get', [
  'sequential' => 1,
  'id' => 1,

The function user_load is deprecated in D9.


Looks like we need a replacement stub function in the drupal module. For a quick hack, you could append this to /var/www/drupal/web/modules/contrib/civicrm/civicrm.module (or wherever it lives on your server).

A better method might be to create a new D9 file of functions that gets loaded selectively only for D9.

/* for when user_load gets deprecated */

if (!function_exists('user_load')) {

function user_load($uid, $reset = FALSE) {
  if ($reset) {
  return \Drupal\user\Entity\User::load($uid);


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.