Home Forums Backend Issues (wp-admin) "Add All" Function


"Add All" Function

  • Hello

    We are using a Relationship field in our WP site to connect events with members (custom post types) and we’d like to know if there is the possibility to add all members from the list to the event (see screenshot). We want to have an “Add all” button i.e. once you click on it, all items from the left list will be added to the second list (on the right). Is there a hook that could manage this please?

    Thank you

  • Hi @lisa-wilson1111

    I’m afraid this is hard to achieve, especially if you have a lot of entries in the list. That’s because ACF uses pagination for the list and will load more entries using AJAX automatically. If you want to do it, please take a look at this page to learn how to use Javascript with ACF:

    Another easier method is to update the list on save. This means that the entries will be added once you saved the contents and reloaded the editor page. You can use the true/false so the user can choose if they want to add all of the entries and then use the update_field() function in the acf/save_post action hook to add them.

    I hope this helps 🙂

  • Hello there,

    I agree that the first option is not really achievable, but I’d like to elaborate on the second one, if that’s all right.

    1) We add the button in HTML
    2) On clicking this button, we bind a JavaScript function toggling a variable say “SelectAll” to true or false.
    3) We’d somehow indicate to the user that All or None are selected.
    4) When user saves the post we use the acf/save_post hook to read our “SelectAll” variable and depending on its value we update the field accordingly. (Add or remove all guest members).
    5) Page reloads and correct result appears in the relation field.

    Can you please confirm my understanding is correct?

    Thank you 🙂

  • Hi @lisa-wilson1111

    Your understanding is correct, but you can simplify it like this:

    1. Create a true/false field type that says “Select all members on save?” and place it after the relationship field. You can also hide the relationship field if the true/false field is selected by using the conditional logic.

    2. When a user saves the post, you can use the “acf/save_post” hook to check if the true/false field is selected. If it is, then update the relationship field by using the update_field() function.

    3. The page is reloaded automatically when the user clicks the save button, so the relationship fields should show the correct result after that.

    I hope this makes sense 🙂

  • Hello,

    This is great, we have got it working thank you!

    Last thing (I hope)

    Looking back at the image i attached, is there a way we can add a search function on the right hand column as well as the left?



  • Hi Lisa,

    I’m afraid that isn’t possible. If you want it, you can submit a feature request by opening a new ticket so the request can be passed directly to the plugin author. Hope he will consider it in the future.

    You can open the new ticket here:

    Thanks 🙂

  • Hello!

    This is a very old post – are there any improvements here in this case?

    The issue is exactly the same as the original request – is there a way to achieve this without saving?

  • Hello!

    This is a very old post – are there any improvements here in this case?

    The issue is exactly the same as the original request – is there a way to achieve “Add all” without saving beofrehand?

  • I’m curious to find out if there has been any improvements on this as well?

Viewing 9 posts - 1 through 9 (of 9 total)

The topic ‘"Add All" Function’ is closed to new replies.