How to set business hours to YES by default

Here is a code snippet to set GeoDirectory Business hours to 'yes' in the add listing form by default

<?php
/**
 * Set Business Hours to open as default.
 */
function gd_snippet_200118_business_hours_set_default( $html, $cf ) {
	global $gd_post;

	if ( ! empty( $html ) && ! empty( $cf ) && ! empty( $gd_post ) && ! empty( $gd_post->post_status ) && $gd_post->post_status == 'auto-draft' ) {
		$html = str_replace( '});</script>', '$("input#' . $cf['htmlvar_name'] . '_f_active0").prop("checked", true).trigger("change");});</script>', $html );
	}

	return $html;
}
add_filter( 'geodir_custom_field_input_business_hours', 'gd_snippet_200118_business_hours_set_default', 20, 2 );

If you are using Ayecode legacy design.  You can use the below code.

<?php
/**
 * Set Business Hours to open as default.
 */
function gd_snippet_200118_business_hours_set_default( $html, $cf ) {
	global $gd_post;

	if ( ! empty( $html ) && ! empty( $cf ) && ! empty( $gd_post ) && ! empty( $gd_post->post_status ) && $gd_post->post_status == 'auto-draft' ) {
		$html = str_replace( '});</script>', '$("input#' . $cf['htmlvar_name'] . '_f_active_1").prop("checked", true).trigger("change");});</script>', $html );
	}
	return $html;
}
add_filter( 'geodir_custom_field_input_business_hours', 'gd_snippet_200118_business_hours_set_default', 20, 2 );
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us