The only required fields when submitting a directory entry are the name fields (first and last for an individual and organization name for a business). To make an email field required, follow these few steps.
First, install the Code Snippets plugin.
Add a new code snippet with the following code, or download, unzip the code-snippet.zip file, and import the code snippet JSON file into the Code Snippets plugin.
add_action(
'wp_head',
static function() {
$process = cnQuery::getVar( 'cn-process' );
$view = cnQuery::getVar( 'cn-view' );
if ( ! in_array( $view, array( 'detail', 'submit' ) ) ) {
if ( 'detail' === $view && 'edit' !== $process ) {
return;
}
if ( 'submit' !== $view ) {
return;
}
}
?>
<style type="text/css">
#cn-form .primary-email-address {
padding: 5px !important;
margin: 2px 4px !important;
font-size: 1.3em !important;
}
#cn-form .primary-email-address.error {
background-color: #FDE9EA;
outline: none;
border-color: #FDCED0;
box-shadow: 0 0 8px #CE0000;
}
</style>
<?php
},
11
);
add_action(
'wp_footer',
static function() {
$process = cnQuery::getVar( 'cn-process' );
$view = cnQuery::getVar( 'cn-view' );
if ( ! in_array( $view, array( 'detail', 'submit' ) ) ) {
if ( 'detail' === $view && 'edit' !== $process ) {
return;
}
if ( 'submit' !== $view ) {
return;
}
}
?>
<script>
selector = '#email-addresses input[type="text"]';
target = document.querySelector(selector);
target.classList.add('required');
target.classList.add('primary-email-address');
target.type = 'email';
target.required = true;
</script>
<?php
},
11
);
Save and activate the new code snippet.
Next, navigate to the Connections Settings admin page and click the Fieldset Configuration tab. Scroll to the Address Fieldset options, disable the Repeatable option, and set the The minimum number of address fieldsets to display. option to 1.
Now the email field will be required before a directory entry can be submitted.
