03/09/2015 at 1:36 pm
#322119
Keymaster
@ William
Understood…
The best way to handle this which will require a bit more up front work but will be update safe is to add your own metabox for phone numbers à la the “Education Levels” extension and then unregister the core phone numbers metabox so you only have one with your modifications. And most of the work is simply copy/pasting.
I would copy the entire code for the phone numbers metabox:
https://github.com/Connections-Business-
- Directory/Connections/blob/8.2.1/includes/class.metabox-entry.php#L1739
Make your changes and register it using the same array attributes:
https://github.com/Connections-Business-
- Directory/Connections/blob/8.2.1/includes/class.metabox-entry.php#L144
Use this method to do the actual metabox registration:
To unregister the core phone number field, this should work:
cnMetaboxAPI::remove( 'metabox-phone' );
You can hook into the cn_metabox
hook to make this happen:
add_action( 'cn_metabox', array( 'cnEntryMetabox', 'init' ), 10 );
Step by step:
- Hook a new function to the
cn_metabox
hook. - The function should unregister the
metabox-phone
metabox. - Set up an array with the exact same attributes.
- Register your custom phone metabox.
Hope that helps.