Toolset Types
[resolved] [Plugin: Types - Custom Fields and Custom Post Types Management] Bug when adding custom field to Typ (6 posts)

  1. helgatheviking
    Posted 4 years ago #

    under custom fields control, these are the steps i take

    1. check the box next to a custom field that I'd like to add to a Types group,
    2. select Add to Group as the bulk action
    3. in the popup, check the box for the group that I'd like the field to be added to
    4. click OK

    the next pop up looks like the screen shot in my link.... basically it is an empty box with the number 0 inside.



  2. helgatheviking
    Posted 4 years ago #

    i hate that you can't edit, b/c I know that admins tend to check on posts w/ no replies first. i'm not bumping my thread, but i've been digging into this and have more info to report.


    i have tracked it down to the fact that admin-ajax.php isn't finding the appropriate ajax action.

    if (open_popup == true) {
                    var data = jQuery('#wpcf-custom-fields-control-form').serialize();  console.log(data);
                    var url = "<?php echo admin_url('admin-ajax.php'); ?>?"+data+"&action=wpcf_ajax&wpcf_action=custom_fields_control_bulk&wpcf_bulk_action="+action+"&keepThis=true&TB_iframe=true&width=400&height=400";
                    var title = jQuery('select[name="'+action_field.attr('name')+'"] option:checked').text();
                    tb_show(title, url);
                    return false;

    taking a look at the resulting console.log(data), i see that the form is already serializing a hidden input called action and it's value is:

    but then a couple of lines later the url is adding another action variable. &action=wpcf_ajax

    so now there are 2 actions defined as GET variables.

    i can trace the wpcf_ajax to

    add_action('wp_ajax_wpcf_ajax', 'wpcf_ajax_embedded');

    so the wpcf_ajax_embedded function exists, but there is no switch case for where wpcf_action=custom_fields_control_bulk.

    but there is also no action hook callback for action=wpcf-add-to-group-bulk which is why admin-ajax.php is dying with a 0.

    hope that info helps

  3. helgatheviking
    Posted 4 years ago #

    ok, i'm back to report that i found the problem.

    in fields-control.php on line 442:

    echo '<input type="hidden" name="action" value="' . esc_attr($_GET['wpcf_bulk_action']) . '" />';

    should be:

    echo '<input type="hidden" name="wpcf_bulk_action" value="' . esc_attr($_GET['wpcf_bulk_action']) . '" />';

    having it be "action" was causing it to fail with admin-ajax.php since wp_ajax_wpcf_bulk_action isn't a valid hook.

    but changing the hidden input to "wpcf_bulk_action" allows the function to correctly set the action to the proper ajax action (wpcf_ajax) which is defined manually on line 296.

    var url = "<?php echo admin_url('admin-ajax.php'); ?>?"+data+"&action=wpcf_ajax&wpcf_action=custom_fields_control_bulk&wpcf_bulk_action="+action+"&keepThis=true&TB_iframe=true&width=400&height=400";

    phew: i guess this is resolved, but i won't mark it as resolved as i hope the devs will see this.

  4. Srdjan
    Posted 4 years ago #

    Hi Helga,
    thanks for finding fix.
    It's applied and will be included in 1.0.3 release.

  5. Srdjan
    Posted 4 years ago #


  6. helgatheviking
    Posted 4 years ago #

    great to hear. glad i could help.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Toolset Types
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic