I’ve written a plugin to extend the Contact Form 7 plugin. I want to add a metabox in the editing area for each form that shows a checkbox that enables/disables the plugin extension.
/**
* Add edit options to each CF7 form
*/
add_action('wpcf7_add_meta_boxes', 'wpcf7ev_add_form_options');
function wpcf7ev_add_form_options() {
add_meta_box('wpcf7ev_form_options', 'Email Verification', 'wpcf7ev_display_options', 'wpcf7_contact_form');
}
function wpcf7ev_display_options() {
wp_mail('myemail@gmail.com', 'debug', 'adding checkbox');
$wpcf7ev_options['active'] = 1;
?>
<input type="checkbox" id="wpcf7ev-active" name="wpcf7ev-[active]" value="1"<?php echo ( $wpcf7ev_options['active']==1 ) ? ' checked="checked"' : ''; ?> />
<label for="wpcf7ev-active">Use email verification</label>
<?php
}
The wpcf7ev_display_options() function doesn’t seem to ever be called though. I checked the post types and one of them is “wpcf7_contact_form”.
What am I missing?
I know this question was asked forever ago, but I found a solution for anyone who’s looking to add custom meta information to Contact Form 7:
What this does is add a filter to
wpcf7_editor_panels
(per Digvijayad’s suggestion) that adds a new panel to the edit screen. That panel contains an input which is part of the form for saving the contact form. Contact Form 7 callssave_post
when we save this form, and our new input and its value are now part of the request, so we can use them to update the post meta on the actual post object in question. Hope this helps someone out.