Skip to:
Content
Pages
Categories
Search
Top
Bottom

Restricting some users from posting in the activities page with user roles


  • RikusWhite
    Participant

    @rikuswhite

    Hey guys.

    I’m new to buddypress and have found it great to work with on my site as I am starting a paid membership community for business users.

    I do have one problem that still hangs over my head. I am trying to restrict some member types from posting activities from their profiles. This will only be available for some users.

    Is there a plug-in that I require? Am I missing something in the setting somewhere?

    Please help out.
    Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi,

    Depending on the theme you use (regular WordPress theme, BP Default or a child of it, or a standalone BuddyPress theme), you can override some templates to achieve your goal.

    Have a look at the codex starting with this page : https://codex.buddypress.org/themes/theme-compatibility-1-7/a-quick-look-at-1-7-theme-compatibility/

    If it’s a regular WordPress theme, then you can can add a buddypress folder in it and copy these templates into it respecting the ‘tree’ :
    bp-templates/bp-legacy/buddypress/activity/index.php
    bp-templates/bp-legacy/buddypress/members/single/activity.php

    Once done, you should have :
    yourthemefolder/buddypress/activity/index.php
    yourthemefolder/buddypress/members/single/activity.php

    Then into these two files search for bp_get_template_part( 'activity/post-form' ); and you should see a line above an if statement containing is_user_logged_in().... Replace is_user_logged_in() by bp_current_user_can( 'theminimumcapability' )

    where theminimumcapability is the the role capability you’re targeting. See the WordPress codex to define it : https://codex.wordpress.org/Roles_and_Capabilities


    RikusWhite
    Participant

    @rikuswhite

    Thanks for the reply.

    Can this also be done with multiple user roles? Say if I have 4 types of user roles that can use the Activities page and I code it like [bp_current_user_can( ‘Role1’, ‘Role2’, ‘Role3’, ‘Role3’, ‘Role4’) ], Will that work? Or do I only need the minimum role level inserted?

    Thanks again for the helpful tip

    No. You’ll need to add a common capability to the roles you are targeting, see
    https://codex.wordpress.org/Function_Reference/add_cap


    RikusWhite
    Participant

    @rikuswhite

    Thanks for the help. It works perfectly.
    I did misunderstood it at first. But also didn’t read it properly.

    Thanks again.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Restricting some users from posting in the activities page with user roles’ is closed to new replies.
Skip to toolbar