Title: Author Access
Last modified: June 26, 2022

---

# Author Access

 *  Resolved [Howdy_McGee](https://wordpress.org/support/users/howdy_mcgee/)
 * (@howdy_mcgee)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/author-access-3/)
 * Hello,
 * How do I ensure that the post author always has access to view their own posts,
   regardless of what Group they may be in?
 * Let’s say a Contributor publishes a post and restricts access to Groups that 
   they are not a part of. How do I ensure that the post author can see their own
   post?

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Kento](https://wordpress.org/support/users/proaktion/)
 * (@proaktion)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/author-access-3/#post-15775879)
 * Hi,
 * The contributor cannot restrict access to a post to groups that he does not belong
   to.
 * > How do I ensure that the post author can see their own post?
 * You need to have the user assigned to the corresponding group, otherwise he won’t
   be able to view the post.
 * Ceers
 *  Thread Starter [Howdy_McGee](https://wordpress.org/support/users/howdy_mcgee/)
 * (@howdy_mcgee)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/author-access-3/#post-15775945)
 * > The contributor cannot restrict access to a post to groups that he does not
   > belong to.
 * Ah then this might not be a great feature request.
 * My use-case is a front-end application where the user can create and restrict
   posts. For documentation purposes, this is how you could allow post authors to
   always see their posts regardless of assigned Groups.
 *     ```
       /**
        * Ensure the post author always has access to their published posts.
        *
        * This is not needed in a default implementation of Groups.
        *
        * @param String $sql
        * @param WP_Query $query
        *
        * @return String $sql
        */
       function wpf15771076_groups_give_author_access( $sql, $query ) {
   
       	global $wpdb;
   
       	if( ! is_user_logged_in() ) {
       		return $sql;
       	}
   
       	return sprintf( 'AND %s OR ( 1=1 %s )',
       		$wpdb->prepare( "{$wpdb->posts}.post_author = %d", get_current_user_id() ),
       		$sql
       	);
   
       }
       add_filter( 'groups_post_access_posts_where', 'wpf15771076_groups_give_author_access', 10, 2 );
       ```
   
 *  Plugin Author [Kento](https://wordpress.org/support/users/proaktion/)
 * (@proaktion)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/author-access-3/#post-15777208)
 * Yeah, it’s not something that I would see as a common use case, but the solution
   for your particular case seems appropriate.
 * Thanks for sharing your approach!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Author Access’ is closed to new replies.

 * ![](https://ps.w.org/groups/assets/icon-256x256.png?rev=983146)
 * [Groups - Memberships and Access Control](https://wordpress.org/plugins/groups/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/groups/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/groups/)
 * [Active Topics](https://wordpress.org/support/plugin/groups/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/groups/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/groups/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Kento](https://wordpress.org/support/users/proaktion/)
 * Last activity: [4 years, 1 month ago](https://wordpress.org/support/topic/author-access-3/#post-15777208)
 * Status: resolved