Skip Navigation

[Resolved] Conditional Display of Form

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

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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 3 replies, has 2 voices.

Last updated by Christian Cox 5 years, 7 months ago.

Assisted by: Christian Cox.

Author
Posts
#1230673

Tell us what you are trying to do?

I have created a count of products.
/**
*Count posts of products
*/
function u_post_count() {
$user_post_count = count( get_posts( array(
'post_type' => 'product',
'author' => get_current_user_id(),
) ) );
return $user_post_count;
}

I have tried to use it in a conditional but it doesn't seem to work

[wpv-conditional if=" ( u_post_count() gt '1') " debug="true"]True if greater than 1 product[/wpv-conditional]

Is there anything obvious I am doing wrong?

#1230718

Hi, if nothing appears in the debug information it indicates a syntax error or an unregistered function call. Did you register the custom function u_post_count in Toolset > Settings > Front-end Content > Functions inside conditional evaluations?

#1230811

Hi Christian,
yes, I registered the function - still can't get it to work. Would there be a different call for products? I also created a loop just for products and used the wpv-items-count but that returned all child posts ids.

#1230970

Are you testing as a logged-in User, or as a guest User? I think this function will give false positives if you test with guest Users. Otherwise it seems to be working fine for me so there must be something else going on. I'll be glad to take a look if you provide login credentials and show me where to find this conditional on the front end of the site.