| User | Post |
|
6:39 am October 1, 2009
| cybertrack
Member
| | | |
|
| posts 3 |
|
|
Hi,
I'm trying to hide or show specific elements on a post depending on a user's permissions. I've tried using
<?php if (is_restricted_rs()){ ?> <p>You don't have permission to download this document.</p> <? } else { ?> <p>Download the file</p> <?php } ?>
but this hides the link from everyone!
Any suggestions?
|
|
|
9:19 pm October 5, 2009
| Kevin
Admin
| | | |
|
| posts 2503 |
|
|
cybertrack said:
Hi,
I'm trying to hide or show specific elements on a post depending on a user's permissions. I've tried using
You don't have permission to download this document.
Download the file
but this hides the link from everyone!
Any suggestions?
Why not just:
if ( current_user_can( 'distinguishing_capability_name', $post->ID ) )…
Or if it's based on their WP role:
global $current_user;
$qualifying_roles = array( 'author', 'editor', 'administrator' );
if ( array_intersect( $current_user->roles, $qualifying_roles ) )...
|
|
|
7:17 pm November 6, 2009
| mbottorff
Member
| | | |
|
| posts 8 |
|
|
I'm trying to do something similar, but what I really want to be able to do is ask if the current user is in a particular group or not.
|
|
|
6:22 am November 8, 2009
| mbottorff
Member
| | | |
|
| posts 8 |
|
|
I paged back until I found an answer, but it uses group ID numbers.
I'd like to be able to use group names instead. Is that doable?
|
|
|
9:07 am November 9, 2009
| Kevin
Admin
| | | |
|
| posts 2503 |
|
|
mbottorff said:
I paged back until I found an answer, but it uses group ID numbers.
I'd like to be able to use group names instead. Is that doable?
You can determine the ID of a group as follows:
require_once( 'wp-content/plugins/role-scoper/admin/groups-support.php' );
$group = UserGroups_tp::getGroupByName( 'your_group_name' );
$group_id = $group->ID;
|
|
|
9:27 am November 9, 2009
| mbottorff
Member
| | | |
|
| posts 8 |
|
|