Try this code: (edited code a little)
add_action( 'template_redirect', 'my_page_template_redirect' );
function my_page_template_redirect() {
global $post;
if( is_user_logged_in() ) {
if( is_single() ){
if( $post->post_author != get_current_user_id() ){
wp_redirect( 'IN ANY PAGE' );
}
}
}else{
wp_redirect( 'IN ANY PAGE' );
}
}
Related Posts:
- How to limit post (Exception pages) for current user in each role in front end?
- each user having category with their name and can add sub categories post in that category
- Allow users to edit post without logging in
- Update post counts (published, draft, unattached) in admin interface
- How to Display a List of Users Who Have Made at Least 1 Post?
- Find out who deleted a page or post?
- Different number of posts in each category
- WordPress: How to get the current logged in author page URL?
- disable password protected page for logged users
- How to limit user to publish post per day and per role?
- Restrict users from editing post based on the age of the post
- Force “Submit to review” when a post is updated
- Restrict access to post if it is currently being edited
- Overview with latest edited posts and pages
- Navigation link to specific user page
- Get how many days since last post of the current user
- Hide comments awaiting moderation from user who submitted the comments
- Query All users that has post
- Limit number of posts a user can make per minute?
- How do I allow users to follow a post and then allow admins to email all users who have followed that post?
- wp_insert_post let users post to without login…broke
- Get user’s most published categories
- Allow anonymous users to post to my site for moderation
- WP_Query posts_per_page ignored
- disable column on post and user list
- Edit Post VS Custom Form
- how to find user ids of all commenters in a post
- How to list users and their post amount?
- Is there any way to allow users to access content before it’s published?
- UberMenu list current user’s posts as menu items
- Limiting the number of posts in WP_Query leads to unexpected result
- Create post for every user?
- count the total number of comments the user has received for his published posts
- Limit posts per author role (excluding admin) in home page
- How to allow logged in users to post anonymously
- Allow public to post on blog
- current post with current author
- How to limit posts by category
- How to verify wp user password by sql query in wp? [closed]
- How can i delay reading posing in 3days for not logined user?
- How can i limit the number of posts created per category?
- Encountering “Wrong nonce. Action prohibitied.” when trying to alter User Role and unable to Post via WP Admin
- Users problem (multi-author plus multisite)
- Increase 10 post limit per page
- How do I manage my users post before publish?
- How do I retrieve a users’ last 5 posts?
- Gather posts into a cart/lightbox and share with another user
- Assign published posts to another user automatically
- query post limits
- Add field to user meta table in database when link is clicked
- Hide comments and posts posted by other user
- Automatically create a default set of posts for each new registered user
- Summary of Posts by an User
- Display a list of users who have viewed the post you are viewing
- Check if current user has a post and that post has any term/s from a specific custom taxonomy outside the loop
- Echo Text If User Is Logged in But NOT the Author of post
- Deleted a user with administrator rights. Now all the data/content/images are lost. how to recover them back
- Custom Post Limit for homepage only without plugin?
- I want to show my post for limited time, how is it possible?
- Show number of posts by logged in user
- How can I set a maximum allowed post size and number of posts submitted?
- Retrieve data from post meta meta_key having ‘_product_fq_image’ while having author_id and post type is PRODUCT
- Setting limit to posts or page creation
- Cannot select certain authors for posts after import
- Limit front-end submitted posts by role
- How can get the last post date of the user?
- Is there a way to save different data when USER interacts with the same POST?
- How to display particular categorie’s post which associated to specific user?
- WordPress Delete Users from backend doesn’t work
- Allow users to post their videos to my wordpress website?
- If user has 1 post then dont let him create new one [closed]
- Compare date of user’s last posts
- Add new post only in assigned category
- WordPress each user has each content for a page,how to do that?
- numberposts not working
- User rank in wordpress post
- Randomize access to post
- Count how many posts a user has viewed
- 3rd Party Login in wordpress
- Allow users to create their own page/s
- Get current user array with post string
- My posts section for logged in user
- How Can I Limit Users to Post Creation For My Frontend Theme?
- How to limit the number of results for all query_posts on mysite
- Set the limit to allow author when make post!
- Show Custom Post From Logged In Author
- Delete old post with new post
- limit posts per page
- How to handle dates, trying to calculate time since a post
- The post order is different for logged-in and non-logged-in users? [closed]
- wp trim function not working
- Allow User Can See His Post on his dashboard
- User submitted post
- Automatically select category based on user role
- Undefined Function Fatal Error with Shortcode [closed]
- How to allow Contributors to edit their own posts, whilst still needing to be reviewed by an admin?
- Does WordPress Super User or Administrators can create and edit post and media on behalf of a user
- Get WordPress post content by post id
- Get page ID of page that is set as the posts page
- Get Posts Under Custom Taxonomy