Support

Account

Home Forums General Issues User meta revisions?

Solved

User meta revisions?

  • I’m building an user form with a revision feature, when the user updates his profile, the admin needs to approve or reject these updates before publish them.

    The user form uses the acf_form() to render on front-end. I tried two ideas:

    1) Save the form array $_POST['acf'] into a meta data serialized named revisions, but after that, it’s a little complicated to work with the data;

    2) Save each field with a prefix _revision_..., using the filters acf/update_value to create this other field and acf/load_value to load the revision field value on the form when the user is still waiting approval. I’m having conflicts here.

    I came here to ask if someone has been done this before, has another idea to help me.

  • What you basically need is two views. For the user you need a view that only shows the fields that the user is allowed to alter. On the second view you need the admin to see both the old and the new updated data.

    I would create 2 fields for each field. One that holds the approved content and one that holds a duplicate of the approved content for editing by the user.

    Let’s say you have a text field, you create two text fields one named text_field_live and the other named text_field_edit. Check out this add on I created recently https://github.com/Hube2/acf-user-role-field-setting.

    Since edits can only be made to the text_field_edit field I would use an acf/load_field filter https://www.advancedcustomfields.com/resources/acfload_field/ to set the text_field_live field as read only $field['readonly'] = 1;.

    Now I’d create a true/false field for Approve Changes that only the admin has access to.

    Now you have two views, one of the user and one for the admin.

    Next I would look create an acf/save_post filter https://www.advancedcustomfields.com/resources/acfsave_post/.

    
    is approved true?
        NO - Return
    
    Copy the edit fields to the live fields
    
    Set approved to false
    
    
  • Thanks John, the filter acf/load_field was a better approach. I’m working on the rest of the script.

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

You must be logged in to reply to this topic.