Customize the message form

Hi i have code:

add_filter(
  'hivepress/v1/forms/message_send',
  function ( $form ) {
    $form['fields']['name'] = [
      'label'       => 'Imię i Nazwisko',
      'type'        => 'text',
      //'required'    => true,
      'min_length'  => 5,
      'max_length'  => 50,
      '_order'      => 1,
    ];

    $form['fields']['email'] = [
      'label'       => 'e-mail',
      'type'        => 'email',
      'min_length'  => 5,
      'max_length'  => 30,
      //'required'    => true,
      'placeholder' => 'noreply@superwypoczynek.pl',
      '_order'      => 2,
    ];

    $form['fields']['phone'] = [
      'label'       => 'Telefon',
      'type'        => 'phone',
      'country'     => 'PL',
      //'required'    => true,
      'placeholder' => '500 000 000',
      '_order'      => 3,
    ];

    $form['fields']['okres'] = [
      'label'       => 'Okres',
      'type'        => 'text',
      'min_length'  => 20,
      'max_length'  => 100,
      //'required'    => true,
      '_order'      => 4,
    ];

    return $form;
  }
);

I have a few questions about it

  1. How to add these fields to messages in messages, currently only the default text field appears.
  2. How to include these fields only in a modal. They will now also appear when replying to a message.
  3. How to add these fields as tokens so that they can be included in the notification email. I have tried to work with this code but not successfully.
add_filter (
  'hivepress/v1/emails/message_send',
  function ( $email ) {
  $email['tokens']['okres'] = ['okres'];

    return $email;
  }
);```
  1. It is possible but it requires overriding the /plugins/hivepress-messages/templates/message/view/message-text.php file with the child theme. Here is the tutorial on how to override template parts Customizing Templates I HivePress Developer Docs - YouTube
    If you are not familiar with the code customization, then please consider hiring someone for custom work https://fvrr.co/32e7LvY

  2. Please try to add this code snippet before $form['fields']['name']

if('messages_view_page' === hivepress()->router->get_current_route_name()){
	return $form;  
}
  1. Sorry, there’s no simple code snippet for this, it would require a custom implementation. If customizations beyond the available features are required for your site, please consider hiring someone for custom work https://fvrr.co/32e7LvY
1 Like

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