Skip Navigation

[Résolu] User meta checkbox doesn't work inside conditional

This support ticket is created Il y a 2 années et 12 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.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

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

Last updated by davidS-53 Il y a 2 années et 12 mois.

Assigned support staff: Minesh.

2020-01-29 11_34_03-Edit User Field Group ‹ ICPKP — WordPress.png

I have a user checkbox field set up with slug college-administrator.

I can output either 1 or 0 just fine with the appropriate shortcode:

[types usermeta='college-administrator' user_current='true' output='raw'][/types]

However, when I try to use it inside a conditional like this:

[wpv-conditional if="( '[types usermeta='college-administrator' user_current='true' output='raw'][/types]' eq '1' )"]
    You're a college admin.

[wpv-conditional if="('[types usermeta='college-administrator' user_current='true' output='raw'][/types]' eq '0' )"]
    Sorry, you're not a college administrator.

It doesn't work. Any ideas why? Thanks in advance.



Languages: Anglais (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

The conditional statement you added looks correct to me.

However - I would like to know, do you want to grab the field value of the current logged in user? If yes, it looks ok to me and you say it is still not working. I need to check why it is not working and for that, I need a problem URL as well as admin access details.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.


I ended up sorting it out myself. That code works perfectly fine placed in a page, but wasn't working inside the page builder I was using. I suspect it was due to the nesting of shortcodes etc.

I ended up just writing a shortcode to achieve the same thing:

function check_college_admin_status() {
	$user = wp_get_current_user();
	$user_id = $user->ID;

	$is_college_admin = get_user_meta( $user_id, 'wpcf-college-administrator', true );

	if ( $is_college_admin == 1 ) {
		return "You're a college administrator.";
	} else {
		return "Sorry, you're not a college administrator.";

add_shortcode( 'college-admin', 'check_college_admin_status');