08/11/2016 at 11:20 am
#386245
Keymaster
@ Jana
Sorry, no, there is no easy way to remove the field. What you could do since you have some coding knowledge is unregister the default address field set and register you own custom fieldset.
To unregister the core address fieldset use this:
function cn_remove_address_metabox() {
cnMetaboxAPI::remove('address');
}
add_action( 'cn_metabox', 'cn_remove_address_metabox', 9 );
To register you custom address fieldset use:
function cn_custom_address_fieldset() {
if ( is_admin() ) {
$pageHooks = apply_filters( 'cn_admin_default_metabox_page_hooks', array( 'connections_page_connections_add', 'connections_page_connections_manage' ) );
// Define the core pages and use them by default if no page where defined.
// Check if doing AJAX because the page hooks are not defined when doing an AJAX request which cause undefined property errors.
$pages = defined('DOING_AJAX') && DOING_AJAX ? array() : $pageHooks;
} else {
$pages = array( 'public' );
}
$field = array(
'id' => 'metabox-address',
'title' => __( 'Addresses', 'connections' ),
'pages' => $pages,
'context' => 'normal',
'priority' => 'core',
'callback' => '{REPLACE WITH YOUR CUSTOM FUNCTION NAME}',
);
cnMetaboxAPI::add( $field );
}
add_action( 'cn_metabox', 'cn_custom_address_fieldset', 9 );
Notice the {REPLACE WITH YOUR CUSTOM FUNCTION NAME} in the above code, you will have to replace that with you own function name for your custom address fieldset.
You can copy the code from Connections and alter it as needed to remove the country field and move the district field. it is this code that you would place in your own custom functions:
- https://github.com/Connections-Business-Directory/Connections/blob/8.5.20/includes/class.metabox-entry.php#L966
- https://github.com/Connections-Business-Directory/Connections/blob/8.5.20/includes/class.metabox-entry.php#L1009
Hope that helps!
