[Resuelto] User meta checkbox doesn't work inside conditional
This support ticket is created hace 4 años, 10 meses. 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.
Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.
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');