No model for attachments in graphql_data_is_private #2481
-
Hi, In this hook, while the item data includes a Should they have their own model? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hey @maurocolella , As you noted, Typically a To distinguish attachments from other post types in add_filter(
'graphql_data_is_private',
function( $is_private, $model_name, $data, $visibility, $owner, $current_user ) {
if( 'PostObject' === $model_name && 'attachment' === $data->post_type ) {
// return some check based on the $owner and $current_user
}
// For anything else..
return $is_private;
},
10,
6
); Let us know if that solves things for you, or if you have any further questions :-) |
Beta Was this translation helpful? Give feedback.
Hey @maurocolella ,
As you noted,
$data->post_type
should showattachment
.Typically a
Model
describes how the data is shaped and not the content that is stored inside of it, and attachments are aWP_Post_Type
hence the model name.To distinguish attachments from other post types in
graphql_data_is_private
, you can do the following:Let us know if that…