• Resolved magician11

    (@magician11)


    I have the following code

    /**
     * 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('[email protected]', 'debug', 'adding checkbox');
    
        //$wpcf7ev_options = get_option('wpcf7ev_options');
        $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
    
    }

    add_meta_box() gets called, but the function wpcf7ev_display_options() never gets called and I’m wondering where I’m going wrong?

    Can someone help please?

    Thanks.

    https://www.ads-software.com/plugins/contact-form-7/

Viewing 1 replies (of 1 total)
  • Thread Starter magician11

    (@magician11)

    The solution to this is

    add_meta_box('wpcf7ev_form_options', 'Email Verification', 'wpcf7ev_display_options', null, 'mail', 'core');

    For some reason supplying the post type wpcf7_contact_form breaks it.

Viewing 1 replies (of 1 total)
  • The topic ‘Trying to add a meta box using wpcf7_add_meta_boxes’ is closed to new replies.