New fields in the Ad Response modal window

I add my fields with this code

add_filter(
    'hivepress/v1/forms/message_send',
    function ($form) {
        // Это условие убирает поля для ввода из истории сообщений (переписки между пользователями)
        if ('messages_view_page' !== hivepress()->router->get_current_route_name()) {
            $form['fields']['fio'] = [
                'label' => 'Ф.И.О*',
                'type' => 'text',
                'min_length' => 6,
                'max_length' => 100,
                '_order' => 5,
                'required' => true
            ];
            $form['fields']['adress_pr'] = [
                'label' => 'Адрес проживания*',
                'type' => 'text',
                'min_length' => 6,
                'max_length' => 100,
                '_order' => 6,
                'required' => true
            ];

            return $form;
        }
    }
);

I have already seen the topic on this issue, but there you just advised me to find someone for revision, and I am a developer myself, but I can’t figure out how to output these new fields so that information from these fields is shown in correspondence, I opened a template file -
/plugins/hivepress-messages/templates/message/view/message-text.php
but I don’t understand how to implement data output from new fields, can you explain in more detail where the data from these fields is stored and how to get them? my task is to add a certain number of fields and to make them appear in the correspondence.
thank you very much and I’m really waiting for an answer

Hi,
Unfortunately there’s no simple code snippet for this, this requires a few changes. You can try adding fields via these hooks:

hivepress/v1/models/message
hivepress/v1/forms/message_send

The model hook is required for the fields to be saved in the database (add the '_external'=>true flag to save fields in the meta). Then you can retrieve field values in template parts this way:

$message->get_fieldnamehere()

The full name in your snippet may also not be required since messages require registration in any case, so you can add user attributes instead (to require the full name and address on registration), for example https://gist.github.com/hivepress/232ba63de5115a56dc21cd7f64c6e52f

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.