Home Forums Backend Issues (wp-admin) modify field look in admin area based on value


modify field look in admin area based on value

  • Is there and option to modify class of the field based on it’s values?
    I have post type X and post type Y, X is shown to user, but using “edit” button form appears where he can change custom fields values and send it to me. Then fields from that form are saved as new post of type Y.

    What i want, is when i go into edit mode of that post Y i want to compare it with same post from type X, simple class change indicating what field have changed will do (ID of the original is saved in a field). Is it doable with load_field or load_value hooks?

  • I think that you can to this with a load_field filter. You could add a class to the wrapper class based on the comparison of values.

    $field['wrapper']['class'] .= ' me-new-class';
  • Thank you! That is what i was looking for, but i have huge memory problem now.
    I’m trying to compare field with field from another post type using global $post, that’s causing my website to Fatal error: Allowed memory size exhausted.
    First i wanted to make one function for acf/load_field hook, but with page never loading i added different functions for different acf/load_field/name= hooks.
    Still it’s not working.

    code looks like this, even for 2 types of the field (or keys) i still get memory limit problems:

    global $post;
    $orig = get_field('original_id',$post->ID);
    if($orig) {
    	$field['instructions'] = get_field($field['name'],$orig); // that line is causing problems
    return $field;

    edit: lol, just clicked “solved” by mistake 😀

  • You could be causing an infinite loop by getting the value from the other post.

    Try using get_post_meta() instead of get_field()

    $orig = get_post_meta($post->ID, 'original_id', true);
Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘modify field look in admin area based on value’ is closed to new replies.