Skip to content

Instantly share code, notes, and snippets.

@KaineLabs
Created September 6, 2018 20:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KaineLabs/868731c98eadeaa5651733a86d9a4adb to your computer and use it in GitHub Desktop.
Save KaineLabs/868731c98eadeaa5651733a86d9a4adb to your computer and use it in GitHub Desktop.
Allow editors to send a messages to all users.
<?php
// Allow editors to send a message to all users.
function yzc_allow_editors_to_send_notices( $retval ) {
// Get Current User Data.
$user = get_userdata( bp_displayed_user_id() );
// Get Roles.
$roles = (array) $user->roles;
if ( bp_is_messages_component() && in_array( 'author', $roles ) ) {
return true;
}
return $retval;
}
add_filter( 'bp_current_user_can', 'yzc_allow_editors_to_send_notices' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment