Support

Account

Home Forums ACF PRO Admin Aproval Reply To: Admin Aproval

  • 21 days later and i think the solution with the true/false field will not work for me. I have over 200 fields and i don’t want to add for every field an extra true/false field.

    What i have:

    JS

    // ##### TEXT #####
    $("input[type='text'],textarea").change(function ()
    {
        // mark input field with red Border
        $(this).addClass('editNow');
    
        // STOP FLOODING
        if(typeof editNow_select_TM != 'undefined') { clearTimeout(editNow_select_TM) }
        editNow_select_TM = setTimeout(function() 
        { 
            var newDataObj = [];  
    
            // get all changed input fields            
            $('#setCardManager_allForms :input.editNow').each(function(e)
            {
                newDataObj.push({   setCardId: $('#setCardManager').data('setcardid'), 
                                    type : 'input',
                                    fieldId : this.id, 
                                    fieldValue : $(this).val() });                                
            }); 
    
            // save to DB
            updateSetCard('select',newDataObj);
    
            // clear Timeout
            delete editNow_select_TM;     
        },1500);
    });
    
    // ##### DROPDOWN #####
    $('#setCardManager_allForms select').change(function ()
    {
        // save to DB
        updateSetCard('select',({   setCardId: $('#setCardManager').data('setcardid'), 
                                    type : 'select',
                                    fieldId : this.id, 
                                    fieldValue : $(this).val() }));
    });    
    
    // ##### CheckBox #####
    $(':checkbox').change(function() 
    {
        // save to DB
        updateSetCard('select',({   setCardId: $('#setCardManager').data('setcardid'), 
                                    type : 'checkbox',
                                    fieldId : this.id, 
                                    fieldValue :this.checked }));
    }); 
    
    // ##### REPEATER FIELDS #####
    $(':checkbox').change(function() 
    {
       // hmmm, not so easy
    }); 

    PHP
    I created a copy from wp_postmeta with the name wp_postmeta_draft.

    The function updateSetCard() store the new values in this table.
    update_post_meta_draft(setCardOpt['setCardId'], setCardOpt['fieldId'], setCardOpt['fieldValue']);

    If the admin confirm

    update_field($selector, $value, $post_id);
    delete row from wp_postmeta_draft

    ACF is new for me so i’m not sure:
    – will this solution work with any problems?
    – did i forget something?

    Thanks in advance and sorry for the late reply.