MenuQueries LibraryDisplay different content to different usersDisplay different content to different usersThis query retrieves the post content, and only for users with the admin role, it appends an "(Edit this post)" link at the bottom of the content. query InitializeDynamicVariables @configureWarningsOnExportingDuplicateVariable(enabled: false) { isAdminUser: _echo(value: false) @export(as: "isAdminUser") @remove } query ExportConditionalVariables @depends(on: "InitializeDynamicVariables") { me { roleNames @remove isAdminUser: _inArray( value: "administrator", array: $__roleNames ) @export(as: "isAdminUser") } } query RetrieveContentForAdminUser($postId: ID!) @depends(on: "ExportConditionalVariables") @include(if: $isAdminUser) { post(by: { id: $postId }, status: any) { originalContent: content @remove wpAdminEditURL @remove content: _sprintf( string: "%s<p><a href=\"%s\">%s</a></p>", values: [ $__originalContent, $__wpAdminEditURL, "(Edit this post)" ] ) } } query RetrieveContentForNonAdminUser($postId: ID!) @depends(on: "ExportConditionalVariables") @skip(if: $isAdminUser) { post(by: { id: $postId }, status: any) { content } } query RetrieveContentForDifferentUsers @depends(on: [ "RetrieveContentForAdminUser", "RetrieveContentForNonAdminUser" ]) { id @remove }CopyPrevDisplay all links in all postsNextDisplay the URLs from all image blocks in a post
This query retrieves the post content, and only for users with the admin role, it appends an "(Edit this post)" link at the bottom of the content. query InitializeDynamicVariables @configureWarningsOnExportingDuplicateVariable(enabled: false) { isAdminUser: _echo(value: false) @export(as: "isAdminUser") @remove } query ExportConditionalVariables @depends(on: "InitializeDynamicVariables") { me { roleNames @remove isAdminUser: _inArray( value: "administrator", array: $__roleNames ) @export(as: "isAdminUser") } } query RetrieveContentForAdminUser($postId: ID!) @depends(on: "ExportConditionalVariables") @include(if: $isAdminUser) { post(by: { id: $postId }, status: any) { originalContent: content @remove wpAdminEditURL @remove content: _sprintf( string: "%s<p><a href=\"%s\">%s</a></p>", values: [ $__originalContent, $__wpAdminEditURL, "(Edit this post)" ] ) } } query RetrieveContentForNonAdminUser($postId: ID!) @depends(on: "ExportConditionalVariables") @skip(if: $isAdminUser) { post(by: { id: $postId }, status: any) { content } } query RetrieveContentForDifferentUsers @depends(on: [ "RetrieveContentForAdminUser", "RetrieveContentForNonAdminUser" ]) { id @remove }Copy