• Resolved Jon Griffith

    (@arretx)


    So, I’m a bit confused. There is a shortcode guide, but I’m needing to edit some of my core template files and include code to restrict content at that level.

    Can that be done?

    As an example, what would I add to a condition in PHP to allow code to be rendered if the user is allowed to view the current page, and restrict if they aren’t, etc.?

Viewing 1 replies (of 1 total)
  • Plugin Author Kento

    (@proaktion)

    Hi Jon,

    Sure that can be done. You would use the API to get the group ID based on the group’s name and then check if the current user belongs to that group. There’s an example here https://docs.itthinx.com/document/groups/api/examples/ on how to check if a user is a member.

    Here’s an example of how you could use that in a template – I’m skipping the part of getting the group and checking that all required functions and classes exist :

    <?php if ( Groups_User_Group::read( get_current_user_id() , $group->group_id )
    } ) : ?>
    <div>Shown to the member...</div>
    <?php endif; ?>
    

    Cheers

Viewing 1 replies (of 1 total)
  • The topic ‘Filtering content at the template level?’ is closed to new replies.