0

Im trying to give the user the option to extend/add the fields for a given metabox using filters using the class https://github.com/bainternet/My-Meta-Box

this is what i have and it shows the fields OK http://pastebin.com/mvFyyKfa

    //array of options
    $clients_info_array=array(
            array(
                    'id'            => 'client_first_name_field',
                    'type'          => 'text',
                    'options'       => array(
                            'name'  =>      'First Name',
                    )
            ),     
            array(
                    'id'            => 'client_last_name_field',
                    'type'          => 'text',
                    'options'       => array(
                            'name'  =>      'Last Name',                           
                    )
            ),             
    );

    $clients_info_array = apply_filters('clients_extra_input',$clients_info_array);


    foreach($clients_info_array as $single_client_info){
            if($single_client_info['type']=='text'){
                    $clients_info_metabox->addText($single_client_info['id'],$single_client_info['options']);
            }
    }

I`m trying to add a new field using this code

add_filter('clients_extra_input','custom_dog_name_field');
function custom_dog_name_field($arr){

    $arr[]= array(
                    'id'            => 'client_dog_name_field_id',
                    'type'          => 'text',
                    'options'       => array(
                            'name'  =>      'Dog Name',
                    )
            );

    return $arr;
}

but no matter where i place it ( functions.php or a new plugin with just that code ) , i cant see the extra field on the metabox.

Am I doing something wrong ?

Thanks

0

1 Answer 1

0

Never mind , i was hooking the metaboxes on plugin_run()

Moved them to admin_menu() and now it works OK

Regards

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.