Change the form messages in the REST API action

Hi there,
I would like to know how I can capture the parameter ‘message’ from a form.
I would like to set it depending on the action I set.

Thanks a lot !

If you mean changing form message depends on form context then please try this PHP snippet to start but please note that it can require further customization. This code snippet change form message for the listing report form

	function($args, $form){
		$form_name = $form::get_meta('name');
		if('listing_report' === $form_name){
			$args['message'] = 'Your content here';
		return $args;

Thanks yevhen.
I think that is not really what I meant.

I have created a custom form, linked to a custom action. My custom action has ‘$request’ for argument. I would like to be able to change the form message directly into my action.
Hope this is more clear.

Thanks a lot!

Sorry, there’s no simple code snippet - this requires advanced customizations.

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

Hi yevhen, thanks for that. I am building my own extension, can you direct me to somewhere in the hivepress source code where something like this is done? I’ve done some research but couldn’t find.

Thanks a lot!

If you mean showing different success messages in the form depending on some conditions in the REST API route action unfortunately there’s no such option at the moment, the success message is set in the form parameters and it can’t be changed from the action (the message is set on the front-end while the action runs on the back-end). There may be a workaround if you customize JS that sets the message, or maybe use the boot function of the form, to check the form context and set different messages before the form is submitted.

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