I am not expert on users, simplest way as for me would be to store ID (or IDs) of user in custom field and check for it if user is not admin.
Some example code (not tested):
if(current_user_can('administrator') || in_array(get_current_user_id(), get_post_meta(get_the_id(), 'allowed_users', true))) {
the_content();
}
else {
echo 'Post restricted';
}
Related Posts:
- How to restrict attachment download to a specific user?
- Using JWT to authenticate a user with an external system?
- Allow anonymous user to access Themes Customizer
- Is there an existing capability to allow editing of only pre-existing pages? If not, a good way to implement this?
- How to make user inactive by default while registering?
- How to set privilege to wordpress subscriber for private page
- authenticate user without password from email activation link [duplicate]
- User Access Manager plugin
- How can we Restrict to access a certain wordpress page to all ip address except some which we allow
- add_option_page capability behaving strange
- Access denied on Published Pages but not on WordPress /wp-admin/
- Allow non logged users to visit only login page and password reset page
- How can I allow users to make groupings of posts
- Is user listing on wordpress private?
- How to restrict logged user to view only certain pages?
- Limit post display to post authors and create an exception for specific pages
- How to “Global Ignore” / “Hell Ban” someone, restrict post visibility to the author only?
- Conditional menu for registerd users/guests (Genesis framework)
- How can I create an upload page for (and only visible to) specific users?
- remove wp admin menu by customer user role
- Custom Roles for access to specific term(s)
- ‘post’ only for editor and administrator
- Why: sticky front page code, shows latest non-sticky on logged-in front page
- Access denied error when logged in as admin
- Disable all admin UI access to authors (except to custom post type add, edit and modify)
- Hide all pages except landing page
- How to restrict access to a page?
- How can I change access permissions across many pages?
- How do I get the access type in WordPress?
- Profiles site with access levels
- User access control in sidebar archive and categorires
- Plugins that restrict access based on user group/roles
- Restrict access for wp-admin panel
- Specify the level of access to different pages at the time of user creation
- grant multiple roles access to specific admin menu item
- When add analytics script, wordpress user login not working
- Hide WordPress “wp-admin” dashboard to User IDS
- I cannot access but but wp-admin works normally
- about visibility in wordpress regarding of roles
- Can access main URL and Dashboard but not any posts or pages [closed]
- How to List only the users created by a particular user
- How to enable to the user send content and save as draft entry?
- How to give members access to their own protected page?
- Use WordPress engine for user registration and management
- How to make future posts visible to selected visitors without login
- Add existing user as administrator
- Split post edit screen into sub-edit screens for users, is this good or bad, and is it possible?
- Suggestions for allowing basic users to view their own posts?
- How to restrict posts only from a certain category
- Two users attempt to modify a page
- How to enable suggested edits?
- How to restrict access to uploaded files?
- wp_update_user not updating
- Can an admin check passwords of registered users?
- How can I hide a category from Contributors in the edit/add new post screen?
- Restrict users on multisite WordPress install
- Basic auth WordPress REST API dilemma
- How to remove “Super Admin” from All Users for those that are not a “Super Admin”?
- Custom user profile, registration, login page with theme
- Restrict the user access in multi site for non-assigned blogs
- moving server can not login
- What is the difference between “create_users” and “add_users” capabilities?
- How can I get multisite primary blog (url or path) for current user?
- Can I create users that have access to *some* other users posts instead of all other users posts?
- Let new user role to ‘edit_others_posts’ of other user role, not of its own type
- Custom post type capabilities require “create_posts” to access the edit posts list page
- Share user table from WP with Drupal
- Log all users out of all locations after 24 hours
- How do I remove the Other Roles field (from User Role Editor plugin) in wp-admin/user-new.php
- Plugin to restrict access to pages in wp-admin
- How to disable a specific page for a specific user
- Subsite access without being a member of the subsite in wp multisite network
- WooCommerce plugin won’t let me access settings
- How to hide a specific part of dashboard for non-admin roles?
- Create custom post with custom user rules
- I can´t access my admin panel. I tried all possible solutions
- Multi-Site Subfolder User Permission Issue
- Plugin creation – how to add user rights?
- Create a WordPress administrator without access to back-end
- User restricted only show posts assigned to current user
- Allow admins to login as other users
- Delete a user from frontend
- How to handle this specific case of custom post type?
- Upload PDF and other files from the Front-End
- User Data Handling between two plugins
- Give users acces to admin a single post or set up WP network?
- if role is logged in then do something
- How do I share a site only to one User at the time? Please help 🥺🙌
- 404 error on new pages but only for non logged in users?
- How does a WooCommerce site integrate with the existing real world customer members?
- Public WP website with one area just for members
- Can I edit domain settings if I didn’t create the site?
- restrict admin panel sections to users
- Allowing users to edit only their page and nobody else’s
- Users are required to login to my site. How define user.member boolean, its permissions, and conditionally display/handle behavior based on it
- How to bulk change user role to “No role for this site”
- Is it possible to restrict a specific user to edit a specific custom post.
- search does not yield access restricted results
- Allowing logged in users to create custom posts
- Is it possible to tell if a user is logged into WordPress from looking at the cookies which are set?