Support

Account

Home Forums Backend Issues (wp-admin) Is get_field_object() dependent on a capability?

Unread

Is get_field_object() dependent on a capability?

  • I’m using get_field_object() to display custom field data in custom columns on the admin list screens (e.g. /wp-admin/edit.php).

    As an admin user, the following code displays the fields perfectly. However, as a custom user role, get_field_object() returns false. I can’t work out what is causing it and given that the code works for some users and not others I can only assume that get_field_object() requires a particular capability to be true?

    add_action( 'manage_properties_posts_custom_column', 'my_manage_properties_columns', 10, 2 );
    
    function my_manage_properties_columns( $column, $post_id ) {
    	global $post;
    
    	switch( $column ) {
    
    		case 'type' :
    			
    			$field = get_field_object('property_type', $post_id);
    			$value = get_field('property_type', $post_id);
    			$meta = $field['choices'][ $value ];
    			
    			if($meta)
    			
    				echo __($meta);
    			
    			else
    			
    				echo __( 'Unknown' );
    				
    			break;
    }
    }
Viewing 1 post (of 1 total)

The topic ‘Is get_field_object() dependent on a capability?’ is closed to new replies.