I'm using the hook before_channel_entry_delete to get custom fields of the deleted entry and use that in another context. But, when I add the hook method and try to get data, all the the custom field values are empty.

For example, the hook method I'm using:

public function hook_before_channel_entry_delete($entry, $values) {

    // Trying to get custom field from $entry
    $field = $entry->getCustomField('field_id_325');
    $value = $field->getData();
    echo 'value field_id_325 - ' . $value;

    // Trying to get custom field from $entry
    echo '<pre>';
    echo '</pre>';


Everything is empty.

I was able to use a workaround by commenting the line: https://github.com/ExpressionEngine/ExpressionEngine/blob/ea47b5f94d4b8e6b2c898af1a856a278c03fc807/system/ee/EllisLab/ExpressionEngine/Model/Content/ContentModel.php#L107 and in the hook method I added:

$entry_tmp = ee('Model')->get('ChannelEntry', $entry->entry_id)->first();
$field = $entry_tmp->getCustomField('field_id_325');
$value = $field->getData();
echo 'value entry_tmp - ' . $value;

In this way I was able to see the value correctly. But I feel that this is not the best, also I don't want to edit core code.

Do you have any suggestions?

Your Answer

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

Browse other questions tagged or ask your own question.