Hi there.
I'm trying to do the same that Bead wrote in this post: https://toolset.com/forums/topic/limit-the-number-of-posts-submitted-by-registered-customers/#post-368894
My custom post type is
Name plural: Negocis
Name singular: Negoci
Slug: negoci
The role user allowed to create is -> Gratuit
I have in my function.php this:
/**
*Count posts of given type, so each user can create post only [desired number of posts] posts
*/
function u_post_count() {
//we create a $variable that holds the value of posts of this user
//we use the count() function <u>hidden link</u>
//we use a get_posts to get the posts of given type, and get_current_user_id() to get the current logged in user
//https://codex.wordpress.org/Template_Tags/get_posts
//https://codex.wordpress.org/Function_Reference/get_current_user_id
//we create the $variable
$user_post_count = count( get_posts( array( //we get the posts
//we define the Post type
'post_type' => 'negoci',
//we get the current logged in author
'author' => get_current_user_id(),
) ) );
//We return the amount of posts created by user
return $user_post_count;
}
ANd this in the page:
[wpv-conditional if="( '[wpv-current-user info='role']' eq 'Gratuit' ) AND ( u_post_count() lt '1' )"]
<b>Això és pel condicional</b>
[/wpv-conditional]
I didn't create any custom post with my user with role Gratuit
But this doesn't show anything. Any idea about what'm I'm doing wrong? Thanks!