0

I created a custom post type with taxonomy and now want to allow users (of a specific user group) to post only one single post in a specific category.

If the user has already posted a post, he can only edit his own post (I already have the PHP for that).

I found a lot of solutions that users can only post in a specific category or only edit their own posts, but no-where an conditional that the user can only post one post.

The functionality might be seen as a "second profile", it should be like a profile (Users can post one post, edit this post, all users and guests can view the post).

I would have several ideas, maybe a conditional, if the user has 0 posts in the category, than he has the right to post?

1 Answer 1

0

You can use WP_Query to get the posts created by user in a specific category as well as a post type.

To find posts of a specific category you can use the following snippet:

$query = new WP_Query( 'category_name=staff' );

Where as to find posts of an author you can use the following snippet:

$query = new WP_Query( 'author=123' );

Combine this in a single query and if the any posts are returned that means user has already created a post.

For reference, check this link

1
  • If you need clarification, please post it as a comment - prior to answering.
    – kaiser
    Commented Sep 30, 2014 at 6:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.