Something like this should do:
function track_editor_wpse_108606() {
if (is_single()) {
$current_user = wp_get_current_user();
if (user_can( $current_user, 'editor' )) {
global $post;
$current = get_post_meta($post->ID,'editor_tracker',true);
$current = (!empty($current)) ? $current + 1 : 1;
update_post_meta($post->ID,'editor_tracker',$current);
}
}
}
add_action('wp_head','track_editor_wpse_108606');
This is not especially efficient. You are reading and writing to the database for these page loads. You could improve this by means of a direct SQL query if you want to go that somewhat risky route, and could improve it further by using Javascript to insert the value if you don’t mind that it won’t work if the user disables Javascript.
Related Posts:
- Advanced search form with filters for custom taxonomies and custom fields
- Help Creating a Slideshow Custom Post Type with Custom Meta Boxes?
- Custom field values deleted when trashing custom post type
- Search multiple custom fields by using meta_query
- Custom Post Type – Taxonomy Dropdown Menu?
- How do I implement custom fields without using any plugins?
- How I check if the same post slug has not been used before publishing?
- How to sort a table of custom posts by column containing custom field
- Issue with saving custom post type when editor is removed
- order by meta_value serialized array
- convert Custom Fields Option-Values to Tags/Taxonomy
- Custom post metadata not appearing in public API
- Automatically Insert Custom Field on Custom Post Type Publish
- Display custom post types with custom date field value (before today) & order by custom date field
- How to have the right design for a custom post type without accessing themes
- How to add the post ID (or any other post data) to a Contact Form 7 mail?
- Create a post in custom post type using field in registration form after users submit form
- WordPress custom meta field for custom post not storing data
- Conditional regex in add_rewrite_rule() for specific query filters & pagination
- How to Duplicate (multiple meta box)?
- List all images from a single post meta value
- Publish an XML feed from a CPT with ACF fields?
- WP_Query: include custom post type only with specific meta value
- Is there a way to get a file URL from the relationship ACF field?
- Want to Add Custom Fields for Uploading video to WordPress Users from front end
- Meta Key Value in current-user-only loop
- Custom Posts Types as Custom Fields
- dynamically add a custom field or metabox to custom post type [duplicate]
- How to implement a Google map store locator
- Random image from tag/custom type on sidebar
- Query & Order posts by custom fields
- retrieve Meta field value from CPT and set those values as Image Meta Field “Title”
- Set a maxlength for the title input in a custom post type
- Update Post Meta for a logged in user
- Problem querying Custom post type by custom fields
- Using custom field content as expression in IF statement [closed]
- ACF From & To Date Validations
- Query Multiple Custom Posts by Custom Fields
- Disable saving posts as draft (make all posts mandatory regardless of the post status)
- Woocommerce custom field search in custom post type [closed]
- Custom REST endpoints for a custom post type with custom fields
- Homepage’s content is dependent on the custom field values (set automatically), how do I get homepage to update without manually updating page?
- Meta Query posts not showing on ending date of custom field
- Cross reference custom post types
- frontend image post uploader
- Custom Post Fields at the beginning of a Custom Permalink
- Possible to filter custom post type with multiple meta data?
- Permalinks: custom structure for taxonomy – tags?
- Create custom post with meta field with AJAX and the WordPress REST API
- Specifying meta field’s column type in Database using add_post_meta
- How to customize work area / admin area in a custom post type without plugins?
- ACF in wordpress
- Creating custom post type with custom taxonomy and custom fields programatically
- delete_post_meta() for whole CPT / multiple posts?
- hide specific div on single.php [closed]
- How to get_term_meta on single custom post?
- posttype and custom fields on multisite
- How to fetch custom post types with its full data on wordpress?
- Custom Fields not showing up for custom post type
- Custom post type in Custom widget – $listItem
- Generating and downloading files with WP API
- Displaying information from custom field on custom post type
- Save Custom Fields
- Custom field only on custom post type?
- Writing a custom Glossary plugin
- Filter search posts by post meta?
- Adding a location field to buddypress activity
- Display Posts that fit a certain criteria on Category pages
- Sort custom post column by generated value?
- How to only display all posts to a custom User Role?
- Unable to gather Image URL from Custom Post Type’s; Custom Meta Field
- Filter posts by their related field’s custom field
- register_rest_field update_callback don’t work for $_FILES
- Custom meta fields not showing up in WP_Response Object via custom endpoint
- Query a Custom Post Type using SELECT that has ACF fields to compare dates
- I want to create a metabox under custom taxonomy
- How can I register multiple custom post fields to json?
- Sql Update CPT from publish to draft and particular custom field
- Filter custom WP_Query by first letter of a custom field – hopefully using Search and Filter Pro?
- sorting in wp query based on custom field value
- PHP Notice: Unidentified index
- check_admin_referer not working in custom meta box for custom post type
- WordPress loop add heading before first of type
- How do i create user accounts from custom posts that have email addresses
- How to display all custom fields associated with a post type – IN THE ADMIN AREA?
- Best way to use Category & Custom Fields?
- How do I add custom fields to posts without having to manually add everytime I post?
- How to display custom post type ordered by a custom field date
- WP_Query and two custom fields returns no posts
- Is it good practice to search for custom posts based on custom field values?
- Custom post type with custom fields enabled, is there a way to set a default group of fileds?
- Storing/querying custom date data
- I want to split this into two functions
- How to store datetime from custom meta box so that it can be sorted by
- Custom Post Meta on a Different Page?
- Custom Post type easy way for editors
- Creating post custom field text area
- querying to custom field over ACF REST API
- WP Query + custom fields: How to query event posts from the current date backwards 6 months and organize it month by month?
- Update Custom Field daily within 7days