## hooks – Lock user information once fields have been filled in

Question

I think this can handle, what you want:

Here is the filter documentation http://www.advancedcustomfields.com/resources/filters/acf_update_value/

You can choose whatever filter option you want, but if you use onw of the first two

add_filter('acf/update_value', 'mr_acf_prevent_update', 10, 3);


You’ll have to write more conditionals on the callback function.

If you use one of these two, you don’t need

// example with the field name
// example with the field key


and the callback that does the job

function mr_acf_prevent_update( $value,$post_id, $field ) { if ( current_user_can( 'manage_options' ) || get_field($field['name'], $post_id ) == '' ) { return$value;

} else {
return get_field( $field['name'],$post_id );
}

}


It can be improved, it’s ugly, but it works!

0
9 years 2013-11-07T01:00:59-05:00 0 Answers 0 views 0