$wrapper->{$field_name}->format throws an EntityMetadataWrapperException

Created on 7 June 2013, about 11 years ago
Updated 15 January 2024, 5 months ago

I tried with the lastest message_notify and entity API versions but I found no reference of this format property anywhere.

I wrote this to send a notification to an user who was requested in an user relationship but as message_notify_send_message was throwing an Exception caught by user_relationships module, the relationship was not saved.

/**
 * Implements hook_user_relationships_save().
 */
function feature_notifications_user_relationships_save($relationship, $action) {
  if ($action == 'request') {
    // Prepare message
    $message = message_create('notify_relationship_ask', array('uid' => $relationship->requestee->uid));
    $wrapper = entity_metadata_wrapper('message', $message);
    $wrapper->field_seen = FALSE;
    $wrapper->field_show_actions = TRUE;
    $wrapper->field_user_ref = $relationship->requester;
    $wrapper->field_user_relationship_id = $relationship->rid;
    $wrapper->save();

    $options = array(
      'rendered fields' => array(
        'message_notify_email_subject' => 'field_message_rendered_subject',
        'message_notify_email_body' => 'field_message_rendered_body',
      ),
    );
    message_notify_send_message($message, $options);
  }
}

Patch following.

πŸ› Bug report
Status

Closed: outdated

Version

2.0

Component

Code

Created by

πŸ‡«πŸ‡·France DuaelFr Montpellier, France

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024