/**
* Allow access to own content only
*/
function my_authored_content($query) {
//get current user info to see if they are allowed to access ANY posts and pages
$current_user = wp_get_current_user();
// set current user to $is_user
$is_user = $current_user->user_login;
//if is admin or 'is_user' does not equal #username
if (!current_user_can('manage_options')){
//if in the admin panel
if($query->is_admin) {
global $user_ID;
$query->set('author', $user_ID);
}
return $query;
}
return $query;
}
add_filter('pre_get_posts', 'my_authored_content');
This will only let admin and the author see the content.
You can either add it to the main functions file or turn it into a
plugin.
Related Posts:
- How to protect post attachments related to a custom post type, from non-logged in users, on 1 subsite of a multisite installation?
- Specific upload folder for PDFs in custom Post type in WP multisite
- Get upload URL by blog ID in multisite
- Multisite stuck at 1MB for max file size
- Which asset URLs are acceptable in a “vanilla” MU install?
- Can upload doc and pdf but not ppt – not permitted for security reasons
- Listing of all uploaded files in network sites
- Troubleshooting a “You do not have sufficient permissions to access this page” error
- Upload path/URL weirdness for the main blog of a multisite/network setup
- Turn off ms-files.php after network setup
- Organize uploaded media files
- How can I have network sites not use year/month folders by default?
- How to upload images manually to wordpress?
- Restrict users on multisite WordPress install
- Sharding BLOGUPLOADDIR
- Advanced Custom Fields Multisite Upload/Imagery Issue [closed]
- How to make WordPress use new Upload Path settings in Multisite Setup
- Hook filter to change wp_upload_dir() path in multisite
- Uploading Images to Multi-Site Causes Failure to HTTP Error
- Shared upload folder in wordpress multisite
- Protect Uploads in Multisite
- Can you have multi-site WP and keep users separate?
- Restrict the user access in multi site for non-assigned blogs
- .epub file blocked despite ALLOW_UNFILTERED_UPLOADS set to true
- How to get max upload size and accepted file types on multisite?
- Multisite Independent User Base
- Force Uploads Use Yearmonth to off (0) for all existing sites in Multisites
- why when I try to insert an image attachment along with a post does wp_get_attachment_url give me a very wrong file path?
- How can I get multisite primary blog (url or path) for current user?
- Images uploading to wrong directory after changing to multisite
- Media library not loading after switching the main site of multisite
- How to stop unlink images when remove a site or user
- Multisite media library uploads broken images
- WordPress Multisite prevent direct access to subdomain
- Upload images from one site to another in Multisite
- access the plugins for each role in WordPress multisite
- Image problem – Multisite image upload broken
- Allow Author on Site A capability to upload files on Site B in Multi Site
- Upload file type not permitted even if explicitly registered as upload_filetypes in the db (multisite)
- Where does multisite store image uploads?
- Error uploading files bigger than 58 MB
- WP doesn’t remove uploads from folder when removed from “Media Library”?
- Problem uploading images
- ‘Cheatin’ uh?’ Error When Attempting to Upload Images After 3.4 Update
- Multisite registration problem [closed]
- Multisite – Images often getting uploaded to the wrong month directory
- Merge Multisites with Shared Network Media Library
- Good way to block users within a multisite setup without deleting them?
- Subsite access without being a member of the subsite in wp multisite network
- Copying media from multisite subsites to main website
- Show media-frame-menu on custom Media Frame
- How to protect specific uploaded files from being accessed by non-logged-in users in WP-multisite
- Multisite sub-directories IIS 7.5 change media/uploads location
- Make uploads live outside of the WP folder
- Multi-Site Subfolder User Permission Issue
- Add access control origin header information across multisite
- Where to set individual blog quotas?
- Save uploads directly in the uploads folder (on a multisite)
- One Site as a part of Multisite to be hidden (Un-published) from Public?
- Multisite adjust uploads like (/upload/%alphanumeric_id%/%file_type%/%blog_ID%)
- Automatically Insert Into Post when uploading Media
- Disable site visiting and user logins excepting for a specific user
- Can I use the same Folder name as a Multisite Blog?
- Multisite missing tmp folder error while uploading
- Common user login for two different wordpress installation and bbpress
- How to check main site user level from subsite in a multisite network
- Give users acces to admin a single post or set up WP network?
- Multisite subdirecty added inside URL to uploaded files
- How To Upload Existing WordPress Site To WordPress Multisite Using SSH
- Remove multisite part from wordpress multisite upload directory
- Users getting linked unwanted to main mu in WordPress multisite (WPMU)
- How to set upload path after renaming uploads folder in Multisite?
- Shared upload folder in wordpress multisite with custom sub site domain pictures URL:s
- WordPress Multisite subdomains and sharing the same upload folder
- WordPress Multisite FQDN Admin Access
- New wordpress uploads are broken
- Primary site file uploads failing, subdirectory subsites upload fine
- Some Subdomains on a Multisite Install Not Found
- Multi site and media uploader
- MP4 upload ok, but HTTP500 if I update the file (multisite)
- Multisite Login Access Restrictions
- How to get blog name, when using WordPress Multisite
- Nginx rules for subdomain multisite install (Bedrock)
- when using add_user_to_blog getting error “Call to undefined function get_userdata”
- Changing admin sub-domain in WordPress multisite
- Update User Role Across Network when Main Site User is Updated
- Get the User ID Who Owns a Given Blog ID in Multisite
- Redirect subdomain in Multisite installation?
- WordPress Multisite logout conflict
- How can I map the primary domain for subsite as subdirectory for another domain?
- Website not listed under Sites (in a Network environment)
- get_site_option / update_site_option – the main site and sub sites do not share the same storage
- Number of total comment does not tally with the number of comment?
- Subsites in Multisite throw 404 in wp-admin
- WordPress theme to support single website but with 3 sections for 3 languages
- Update siteurl and home in multisite subsites to https
- WordPress multi-domain with multiple sites with multiple languages
- Domain level problem for multisite?
- Redirect www.mainsite.com/subsite/wp-login to www.mainsite.com/wp-login
- How does adding custom meta to signup form work?