I’m trying to show the contents only for certain registered users. All users have the role of “agent”. To hide the contents of an unregistered user, I use this code:
<?php if ( current_user_can( 'agent' ) ){ ?>
///here the content
<?php } ?>
Now I want to show the contents only for users with id 8,9, with this code:
<?php if ( current_user_can( 'agent=8,9' ) ){ ?>
///here the content
<?php } ?>`,`<?php if ( current_user_can( 'author_name=Jacks,David' ) ){ ?>
///here the contents
<?php } ?>
But nothing happens!!!
Please help.
To show content only for users with role ‘agent’, try to use this snippet:
If you want to block users by ID, check the following snippet: