Skip to:
Content
Pages
Categories
Search
Top
Bottom

Option – This is a notice to all users


  • Basti
    Participant

    @afu24

    Hi,

    is it possible to grant the permission send a notice to all users for a new role called “trainer”: http://fs5.directupload.net/images/160217/qv6i4jy3.jpg

    As I found out its just possible for an admin.

    I use the plugin “members” to manage roles. Is there a special Capability?
    Any way to do so? Any hacks or workarounds?

    Many thanks in advance!

Viewing 10 replies - 1 through 10 (of 10 total)

  • shanebp
    Moderator

    @shanebp

    Create a template overload of this file:
    buddypress\bp-templates\bp-legacy\buddypress\members\single\messages\compose.php

    Adjust the conditional that shows the checkbox so that the ‘trainer’ role is allowed.


    Basti
    Participant

    @afu24

    Thanks @shanebp! Got it. Works perfectly for me 🙂


    Basti
    Participant

    @afu24

    @shanebp: ok,
    i changed “bp_moderate” to “create_users” at line 29 in compose.php
    as I set this for the trainer role too:

    <?php if ( bp_current_user_can( 'create_users' ) ) : ?>
    		<p><label for="send-notice"><input type="checkbox" id="send-notice" name="send-notice" value="1" /> <?php _e( "This is a notice to all users.", "buddypress" ); ?></label></p>
    	<?php endif; ?>

    The changes works and the option field “send a notice to all users” displays also for trainers with capability “create_users”.

    BUT they can’t send notices at all/ still miss the capability and also don’t have the “notices” menu in the buddypress profil.
    An Error Message appears when they try to send message as site wide notice: “Notice was not created. Please try again.”

    What else do I have to change? I looked at other php files around there but didn’t find a solution. Can you help me out? Thx!


    shanebp
    Moderator

    @shanebp

    The function that sends notices
    function messages_send_notice in bp-messages\bp-messages-functions.php
    has a hard-coded check for bp_moderate: bp_current_user_can( 'bp_moderate' )

    By default, ‘bp_moderate’ is only assigned to site admins.

    Did you try giving the bp_moderate capability to trainers?

    also – create_users is a very powerful capability, perhaps unsuitable for a role other than site admin.


    Basti
    Participant

    @afu24

    Hi thx for your fast reply.

    Ok I would like to try it the other way round.

    I use the plugin Members to set capabilities and create new roles e.g. “trainer”. I tried to to add “bp_moderate” as a custom capability – buddypress capabilities are not listed there – but it didn’t work. Is the name wrong? Or is there no option to add this capability? As I read after some search here that buddypress have no connections to normal wp roles or capabilities.

    Or what did you mean?


    Basti
    Participant

    @afu24

    Ok now bp_moderate is obviously added in the list (in the plugin members) and granted to trainers but it doesn’t affect the site wide notices (still disabled).
    The only thing who seems to affect it is the capability manage_options but I wouldn’t like to grant them to trainers.


    shanebp
    Moderator

    @shanebp

    Look at
    function _bp_enforce_bp_moderate_cap_for_admins
    in
    bp-core\bp-core-caps.php

    Note: // Only users that can 'manage_options' on this site can 'bp_moderate'

    So try adding that cap to trainers.

    You could also write a function that also uses the map_meta_cap hook, but with a larger number re priority so that it runs after the function noted above.


    Basti
    Participant

    @afu24

    Yes, when I grant the Trainer role the manage_options capability it works – but I won’t like to use this option.

    I can’t override bp-core-caps.php and change 'manage_options' to e.g. 'create_users' right?

    You could also write a function that also uses the map_meta_cap hook, but with a larger number re priority so that it runs after the function noted above.
    – sorry I didn’t get this. My knowledge of coding is near zero


    Basti
    Participant

    @afu24

    @shanebp: any ideas?
    Can not be that no one previously had that problem :DD


    Basti
    Participant

    @afu24

    Nobody who use this feature for roles besides admin?
    Any other ideas how can I solve my request?

    I wouldn’t prefere to install another plugin for site wide notices, because I really like this option from buddypress combining popup/ widget and notices in the message inbox 🙂
    It’s only that admins can use it right now.

Viewing 10 replies - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.
Skip to toolbar