Skip Navigation

[Resolved] Per user is allowed submitting one post only

This support ticket is created 6 years, 6 months ago. 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.

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 replies, has 2 voices.

Last updated by Luo Yang 6 years, 6 months ago.

Assisted by: Luo Yang.

Author
Posts
#864601

Hello, A few days ago, I opened the same ticket, https://toolset.com/forums/topic/submitting-one-post-per-user-allowed/ but I changed something recently making the function no longer working, I have been working on this few hours, I think I am not able to fix it, so please help me with this again if possible. similarly, please send me a private link, I will share some description of what and where happened. Thank you so much!

#864942

Hello,

Thanks for the details, I can login your website, please point out the problem page URL, where I can see the problem:
the function no longer working

And where I can edit your PHP codes, I need to debug in your website, thanks

#865933

OK, I checked again the old ticket, and I have change the codes to below, please test again:

...
	  		$args = array(
			  'post_type'        => 'guest',
			  'author'	=> $user, 
			  'post_status' => 'any',
			  'fields' => 'ids'
			);
	  		$posts = get_posts($args);
            $user_post_count = count( $posts );
...

The function count_user_posts() only counts the published post, in your case, it needs to count post in draft status, so you can use get_posts() directly, more help:
https://codex.wordpress.org/Function_Reference/get_posts