Tell us what you are trying to do? Hide sections of a page using Access Conditionally Displayed Text
Is there any documentation that you are following? Just the using shortcodes and API in php templates
So I ended up with something like this:-
<?php echo do_shortcode("[toolset_access role='Team Leader' operator='allow']"); ?>Team Leader Only Content Here<?php echo do_shortcode("[/toolset_access]"); ?>
but this does not work.
Can I use Access in php templates to hide sections based on user role? And if so, how?
Many thanks,
D
Nigel
Supporter
Languages:
English (English )
Spanish (Español )
Timezone:
Europe/London (GMT+00:00)
Hi David
I haven't tried it, but your code is problematic, you need the entire shortcode and content in a single string that is passed to do_shortcode, e.g.
$protected = "[toolset_access role='Team Leader' operator='allow']Team Leader Only Content Here[/toolset_access]";
echo do_shortcode( $protected );
Do you want to try that?
Thanks Nigel, I'll give this a go and get back to you.
Quick Question: Can I put line 1 into the functions file and line 2 in my template?
Nigel
Supporter
Languages:
English (English )
Spanish (Español )
Timezone:
Europe/London (GMT+00:00)
Probably not, unless $protected is in the global scope, though you can enforce that by including global $protected; in both files before using it.