You can use current_user_can()
and is_user_logged_in()
to validate current user:
<?php if ( is_user_logged_in() && current_user_can('role') ) : ?>
<span style="font-size:16px">
<strong>Currently reading:</strong> <?php the_field('book_name'); ?> (<?php the_field('book_year'); ?>)<br/>
<strong>Currently seeing:</strong> <?php the_field('movie_name'); ?>"><br/>
</span>
<?php endif; ?>
Make sure to change role
to your preference and take a look at Codex for more info.
Related Posts:
- Order posts by custom field and if custom field is empty return remaining posts
- Calling Specific Pages with wp query Part II
- Loop through two different sets of custom fields
- How do I exclude posts by custom field value?
- Echo values from custom field outside loop php
- Upcoming Event: How do I sort database by custom date field, but ignore past dates?
- Calling custom fields for pages (not posts)
- Duplicate posts being displayed when querying Custom Fields
- Loop to display random posts only if a custom field matches category
- get_posts that match a user-specified value on a page
- Accessing loop functions (e.g the_title or the_content) from post ID
- Limit the number of acf content when displaying in post loop [closed]
- Is there a better way to list all database terms alphabetically?
- Change the main loop WordPress impact on the server?
- custom-meta-box checkboxes from loop won’t save
- How to show a post if was published less than two hours ago?
- List users by sum of all their posts’ custom field values
- Custom Fields – How to create a list from multi-line entries of a single value
- how to make nsfw post with thumbanil
- Custom Query based on custom field of a single post
- Efficiently sort only certain categories by custom field
- Can I access a post meta field before the loop?
- Displaying page image in the footer automatically
- Show image if author meta (profile fields) exists outside loop
- Can’t query by meta_key
- ul list with only as many li’s as filled custom fields
- Loop through incrementing custom fields
- do_shortcode close
- Search Results Page – Displaying Custom Meta Fields
- Interrogate a page within a loop to check template type or custom meta data (Pages vs Posts)
- Collect Data from NEXT item while in loop
- How to show content of custom fields in search results?
- Custom field outside the loop and inside an array
- Display metabox title for custom fields with values
- use custom field value as post category in loop
- Filter or order based on custom field
- Compare ACF date field (if exists) and post date and order DESC
- What am I missing in this Code Block?
- get_field values for each post on home page using wp_add_inline_style
- User Filter Options on Archive Page
- Custom meta boxes – add php code inside?
- get wordpress post loop by meta box date
- Outputting custom field on home.php not outside of blog list
- Counting number of images from loop
- Metabox value for post loop?
- Get meta value when the page is a blog archive
- WP_query returns error when used for custom widget
- I want my post to republish again after adding a custom field
- Display posts where date field matches current month?
- Filtering posts by WORD in custom field
- Retrieve IDs from custom field, count and display results differently according to count
- Pagination not displaying correct number of pages
- Display custom field outside the loop
- Custom field not showing
- Order by a meta field in query loop
- Custom post meta field effect on the performance on the post
- Difference between meta keys with _ and without _ [duplicate]
- Add custom objects/entities to WordPress
- Plugins won’t recognize my plugin’s hidden custom fields
- Store JSON in a custom field
- Change loop order via form or link (jquery, not URL)
- Best way to add custom / magic / flutter fields into RSS feed
- Setting orderby to a custom field using pre_get_posts
- How to get multiple checkboxes in one meta field
- Adding Custom Fields to Search
- How to Display Custom Meta Box only on Specific Page IDs
- How do I use Ajax to build a dropdown of custom fields based on a post selected in previous dropdown?
- Register rest field for specific user
- Custom Field Suite A little problem
- How to create a Custom Meta Box with Name/Value Admin User Input Fields?
- Custom Fields box in the post editor: Replace textareas with input elements
- Passing args to WP_User_Query am I using meta correctly?
- Hide custom column in admin template screen (Elementor) [closed]
- ORDER BY custom field value out of where clause
- How can i retrive a text from a custom field
- ACF: How to get users with a ACF flexible content subfield with a specific value AND layout?
- Is it possible to populate a custom field with content from a page
- WordPress loop by meta key that is an array? and how loop multiple arrays
- Save all custom field data into one “master” custom field
- How to put forward a blog post
- Display latest post depending on Meta Box content
- Custom fields won’t update
- Replacing custom field with shortcode
- WPAlchemy issue when using 2 select menus with the same values inside a repeating group
- Is the use of many custom field not good for server?
- Very large list of options for BuddyPress profile fields
- Custom meta fields not showing up in WP_Response Object via custom endpoint
- Can you generate a featured image from two images from custom fields?
- Change Order of Sections Using Custom Fields
- How to add content with a filter when there’s no content in the editor
- Order a query by meta_value and then by post_date
- custom field functionality
- WordPress archives by custom field and date
- Decouple page name from page title
- Custom Field add markup to line breaks
- Use Metabox to enter Post Title
- Include custom fields into the content of a regular page
- i want to send email on custom post field (job_status == 2) but it is not working
- How to create a searchable database with a single-field search box at the front end? [closed]
- How to add an ACF only for parent term?