Cannot add to listing description custom field information

I need to add a custom field textArea to the description of my listing, i used this code but is not working, can you validate please:

add_action('hivepress/v1/models/listing/update', 'custom_set_listing_description', 1000, 2);

function custom_set_listing_description($listing_id, $listing) {

            //remove_action('hivepress/v1/models/listing/update', 'custom_set_listing_description', 1000);

   

            $description = null;

            echo 'TESTE';

            if ( $listing->get_listing_required() ) {  //this is  my custom field  and is filled because i tested in front end and have content

                $description = $listing->get_listing_required();

            }

           

            // Save description.

            if ($description !== null && ($listing->get_description() !== $description)) {

                $listing->set_description($description)->save_listing();  //Or save_description() is not working

            }

    }

Hi,

If I understand you correctly, please use this PHP snippet (How to add custom code snippets - HivePress Help Center):

add_filter(
	'hivepress/v1/forms/listing_update',
	function( $form ) {
		$form['fields']['description']['description'] = 'custom text here';

		return $form;
	},
  1000
);

Please note that it can require further customization.
If customizations are required for your site, please try customizing it using the collection of code snippets Search · user:hivepress · GitHub and other developer resources, or consider hiring someone for custom work https://fvrr.co/32e7LvY

Hello Andri,
The text I need to be inserted on description need to come from other field. In this case is a custom field I created on Listing, is also a textArea, so when showing instead of showing in a new field on frontend I would like to concat in Description.
Regards

Hi,

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

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