Resources

My Agape try

Your Agape try


Support Forum

You must be logged in to post Login Register

Search 
Search Forums:


 




Hiding elements on a page by group

UserPost

6:39 am
October 1, 2009


cybertrack

Member

posts 3

1

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

2

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

3

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

4

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

5

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

6

Thanks!


About the Agapetry forum

Currently Online:

11 Guests

Maximum Online: 150

Forums:

Groups: 2

Forums: 7

Topics: 1247

Posts: 5656

Members:

There are 1259 members

There are 1 guests


Kevin has made 2503 posts

Top Posters:

metal450 - 178

Ragnar - 108

YikYak - 70

whiteorb - 49

Daisy - 35

Administrator: Kevin | Moderators: Kevin