Skip Navigation

[Résolu] Author only view custom posts they created

This support ticket is created Il y a 8 années et 3 mois. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 2 réponses, has 2 voix.

Last updated by joshD-2 Il y a 8 années et 3 mois.

Assisted by: Luo Yang.

Auteur
Publications
#356366

Hello,

I'm looking for the code to put in my single-custom_post.php file to only allow a user to view posts he/she created. If they did not create the post, I'd like to redirect them back to a URL.

I have:

if ( ! ( is_user_logged_in()|| current_user_can('publish_posts') || $current_user->ID == $post->post_author ) ) {

}

which isn't working

#356388

Dear josh,

Please try this:
get_current_user_id() == get_the_author_id()

More help:
https://codex.wordpress.org/Function_Reference/get_current_user_id
Returns the ID of the current user.
https://developer.wordpress.org/reference/functions/get_current_user_id/
Get the current user’s ID

#356468

Thanks Luoy, this worked

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.