Support

Account

Home Forums Backend Issues (wp-admin) Order of forms not being kept

Solved

Order of forms not being kept

  • (Using ACF 5.4.7)

    I’m having trouble setting the order, hide_on_screen, and description attributes on my forms. There are two forms that I’m using one that holds submitted values from the front end (e.g. name, email, etc…) and one for an admin. I’d like the order on each backend post page to be submitted values, admin form, everything else. To do that, I set the “order no.” to 0 for the first, and 1 for the second. I then exported to php and included it in the plugin I’m working on.

    However, I’m still getting the order I had before (admin, everything else, submitted values). Additionally the “Hide on screen” targets I checked off aren’t being hidden and the descriptions I added aren’t being displayed.

    I changed one of the fields from required to not required and that updated correctly but not these other attributes. Can anyone offer insight on how to fix this?

  • Hide on screen values will only be effective for the first field group loaded. This load order is set by the “Order No.” value of the field group.

    Description is only shown on the ACF admin.

    How are your field groups added? Are they only in the admin or are they added using PHP?

    WP remembers the order that the field groups were displayed and shows them in that order, even when you later change that order in the field group settings. These values are stored in the _usermeta table per user per screen, the order of meta boxes on the post screen for example are stored with the _usermata meta_key of “meta-box-order_post”. As far as I know, the only way to clear reset this is to go into the database and delete it. I did locate some code that might allow you to set the order here http://wordpress.stackexchange.com/questions/15376/how-to-set-default-screen-options

  • @hube2 Thanks for the clarification. Now that I’ve checked, those other attributes are working correctly. I’ll try something like the code you’ve linked to.

  • After some research and trial and error, here’s what I’ve come up with. For my case it turns out you don’t necessarily need to do anything re the database directly. I used two functions.

    1

    function move_wysiwyg_editor() {
      global $post;
      global $wp_meta_boxes;
      do_meta_boxes(get_current_screen(), 'normal', $post);
      unset($wp_meta_boxes[get_post_type($post)]['normal']);
    }
    add_action('edit_form_after_title', 'move_wysiwyg_editor');

    2

    function remove_plugin_metaboxes() {
      remove_meta_box('id_of_metabox_from_plugin', 'request_form', 'advanced');
      // repeat as needed
    }
    add_action('do_meta_boxes', 'remove_plugin_metaboxes');
Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.