Customization of the Listing Submission: Conditional Fields and Upload Limits

Hello,

I would like to modify the listing submission page:

1/ By displaying the fields sequentially.
In other words, the next fields should only appear if the previous ones are filled in.
To achieve this, I plan to use JavaScript with jQuery.
However, I can’t find the right way to integrate my JavaScript, nor how to modify the overall layout of the page.
I would like to use Divi, but I understand that I might not be able to for this specific page (no available shortcode?).

2/ I also want to limit the number of image uploads.
For example, by default, users could upload up to 3 photos, and depending on the subscribed offer (e.g., premium pack with X photos), this limit would change.
Support previously mentioned via email that this feature would be implemented in the first quarter of 2025. Can you confirm this?

3/ It seems possible to reorder the attribute display using a hook.

Thank you in advance for your help.

Hi,

  1. Yes, this would require code customizations. Please try to target fields by name within the listing submission form, and checking if the fields are changed, showing or hiding dependant fields. Each field has a unique name so it’s possible to target them and use listeners like .on('change'.... There may also be some workarounds, e.g. instead of 2 dependant drop-down fields it’s possible to use a single hierarchical one.

  2. We plan to release the initial version of this extension in 2 weeks.

  3. If these are custom attributes, please edit them in Listings/Attributes, you can set custom order in the Order field. For built-in fields, it’s possible to re-order them using the hivepress/v1/models/listing/attributes filter hook.

Hope this helps

Hi,

Thanks for your response!

Regarding the sequential display of fields, I understand that I can target fields by name and use event listeners like .on('change', ...). However, my main issue is finding the best way to properly integrate my JavaScript into the listing submission page.

Where should I add my script so that it runs correctly on this page? Should I enqueue it in a custom function, or is there a recommended way to insert custom JavaScript specifically for this form?

Thanks again for your help!

Hi,

If you are using a child theme, you can connect JS using this function: wp_enqueue_script() – Function | Developer.WordPress.org
However, if you are using the Code Snippets plugin, then there should be a default JS script example.

​I hope this is helpful to you

Hi,

Thanks for your reply!

I am using a child theme, and I am looking for the best way to integrate my JavaScript only on the listing submission page. What would be the most suitable method for this? Should I use a specific conditional tag or hook to properly target this page?

As a developer, I always aim for optimized solutions in terms of loading time and performance. From what I understand, your suggested approach doesn’t seem to be the most efficient in this regard. Could you clarify whether there is a more lightweight or optimized way to handle JavaScript integration specifically for this form?

Do you also have any documentation or examples on customizing the submission form with JavaScript?

Thanks again for your help!

Hi,

Please note that inserting JS is a general WordPress question and it is not HivePress specific, but you can use this sample where you need to replace the page URL where you want to add JS:

add_action(
	'wp_print_scripts',
	function() {
		if ( is_admin() || hivepress()->router->get_current_url() !== 'add page URL here' ) {
			return;
		}
		?>
		<script>
			// add JS code here
		</script>
		<?php
	}
);

​I hope this is helpful to you

Hi,

Thanks for your response.

I understand that adding JavaScript is a general WordPress topic, but my question is specifically about the best way to integrate JavaScript into the HivePress listing submission form in an optimized way, without unnecessary checks.

Your suggested approach using wp_print_scripts works, but it seems inefficient to check the current page on every script execution just to inject JavaScript inline. I am concerned about potential performance issues on my site, which will experience high traffic, and every unnecessary check could have a significant impact on performance. The ideal solution would be to load the script only when the relevant page is loaded, without executing redundant checks on other pages.

Wouldn’t it be more optimized to enqueue a separate JavaScript file only when the listing submission page is loaded, using wp_enqueue_script() with the appropriate dependencies? A better approach could be having a dedicated hook that allows scripts to be loaded at the template level of the submission page, rather than relying on global script injections.

Additionally, could you confirm whether HivePress provides any specific hooks or methods to extend the submission form functionality in a clean and structured way, avoiding unnecessary JavaScript manipulations?

Thanks again for your help!

Hello,

I feel your pain.
I could not find the appropriate template php file (the wordpress classic way), so I had to rely on this instead :

if ($_SERVER['REQUEST_URI']=='/add-your-url-here/'){
outputJS('some text); 
}


function outputJS($msg){
	$output =  '<script type="text/javascript">
            jQuery(document).ready(function ($) {
				$("h1").append("<span class=\'pos\'><i class=\'hp-icon show-tooltip fas fa-info-circle\' title=\'Aide\'></i></span>"); 
				$(".hp-page__title").after("<div class=\"tp-tooltip\">'. $msg .'</div>");
			});</script>';

	print $output; 
}

1 Like

I recommend using the suggested code snippet, this check for the current URL doesn’t affect any performance (checking the current URL doesn’t query the database, it’s a simple PHP runtime check and WordPress does thousands of similar conditional checks on every page refresh). Performance is mostly affected by complex database queries or client-side content (JS/CSS, image optimization).

If you don’t want to add inline JS, you can add the “script” tag in the same snippet with the script URL, or use the same approach with checking the current URL but for the wp_enqueue_scripts hook.

The functionality you described (conditional fields visible or hidden depending on the selection) is not in the form yet so custom JS logic would be required here in any case.

Hope this helps

Hi,

Thanks for your clarification. I understand that there is no dedicated hook for this at the moment, so I’ll proceed with the suggested approach.

I appreciate your help!

Best regards,

1 Like