user = entity_metadata_wrapper('user', $userpoints_transaction->uid); $userpoints_transaction->entity = NULL; if (!empty($userpoints_transaction->entity_type) && !empty($userpoints_transaction->entity_id)) { // Make entity available as lazy loading wrapper. $userpoints_transaction->entity = entity_metadata_wrapper($userpoints_transaction->entity_type, $userpoints_transaction->entity_id); } // Invoke rules event. rules_invoke_event($event, $userpoints_transaction); // Convert back to keep any changes to the properties. $params = (array)$userpoints_transaction; $params['uid'] = $userpoints_transaction->user->getIdentifier(); unset($params['user']); if ($userpoints_transaction->entity) { $params['entity_type'] = $userpoints_transaction->entity->type(); try { $params['entity_id'] = $userpoints_transaction->entity->getIdentifier(); } catch (Exception $e) { throw $e; } } unset($params['entity']); } }