After programmatically create user I get error - "Notice: Undefined property: stdClass::$uid in htmlmail_user_presave() (line 179 of /sites/all/modules/htmlmail/htmlmail.module)."
Here is the code with which I created the user:

<?php
    $new_user = array(
        'name' => $form_state['values']['name'],
        'pass' => $form_state['values']['pass'],
        'mail' => $form_state['values']['email'],
        'status' => 1,
        'access' => REQUEST_TIME,
        'roles' => array(
          DRUPAL_AUTHENTICATED_RID => 'authenticated user',
          // Customer role ID = 5.
          5 => 'customer',
        ),
      );
      // Create user.
      if (user_save(NULL, $new_user)) {
        drupal_set_message("You have successfully register!");
      }
      else {
        drupal_set_message("Registration error!", 'error');
      }
    ?>

After that user successfully created with this error.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

hamrant created an issue. See original summary.

hamrant’s picture

Status: Active » Needs review
FileSize
756 bytes

My minor fix.

Status: Needs review » Needs work

The last submitted patch, 2: htmlmail-user-presave-undefined-property_2666086-1.patch, failed testing.

jacob.embree’s picture

Issue summary: View changes
Status: Needs work » Needs review
FileSize
617 bytes
salvis’s picture

Status: Needs review » Needs work

Thank you for the patches, hamrant and jacob.embree!

#4 has the correct format now, but you've added a trailing space:

+++ b/htmlmail.module
@@ -176,7 +176,7 @@ function htmlmail_form_user_profile_form_alter(&$form, &$form_state) {
+  if (isset($account->uid) && $account->uid > 0) { ¶

Please remove it to conform to the Drupal Coding Guidelines.

jacob.embree’s picture

Assigned: hamrant » Unassigned
Status: Needs work » Needs review
FileSize
616 bytes
641 bytes

  • salvis committed 75401d8 on 7.x-2.x
    Issue #2666086 by hamrant, jacob.embree: Notice: Undefined property:...
salvis’s picture

Status: Needs review » Fixed

Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.