Both password protected and private posts doesn't seem to work for metaboxes. Anything that is added in the editor (the_content) it is protected but all contents added by metaboxes is displayed.
Thanks, it works well but I am looking for a way that password protection applies to all registered metaboxes, otherwise I need to add the conditionals in every place that I display a metabox field.
WordPress hard-coded that in its function get_the_content, so there's no filter to do that automatically. Maybe you write a wrapper function for rwmb_meta like this:
function your_meta( $field_id, $args = [], $post_id = null ) {
if ( post_password_required ) {
return 'This post is password protected.';
}
return rwmb_meta( $field_id, $args, $post_id );
}
Is there a way to display a custom field only to authenticated users regardless of role? We have some fields in security docs that we would like to display to our employees but not to the world. Most of the other custom fields are OK for public display.