Home › Forums › Front End PM PRO › Allow sending even if not a member of the receiving group?
- This topic has 11 replies, 2 voices, and was last updated 3 years, 5 months ago by Shamim Hasan.
-
AuthorPosts
-
June 23, 2021 at 4:16 am #43243wayne.schulzParticipant
How do I allow a certain user or member of a group to send to any other group (even if they are not part of the receiving group)?
We are using your plugin on our staff site and wish to allow certain users or groups to send to other groups even if the sender is not a member of the receiving group (ex: a member of manager group sending to all members of department group). I tried making them an FEP admin and that seemed to do nothing (even website admin had no access unless a member of the receiving group).
June 23, 2021 at 3:27 pm #43246Shamim HasanKeymasterYou can follow https://www.shamimsplugins.com/support/topic/allow-only-admin-to-message-groups/#post-36544
Or if you want to allow multiple user role users to send group message you can follow https://www.shamimsplugins.com/support/topic/question-about-groups-messages/#post-28661 (change roles as you want)June 23, 2021 at 8:49 pm #43249wayne.schulzParticipantThank you for your reply, however, members of the manager and/or administration group still can only send to groups they are members of? I require managers and administration to be able to send to any group (or a select set of groups) even if not a member of.
When setting up groups in Front End PM, I used the {role-unparsed}-rolename for each group that our site has (if that has an impact on anything). Which BTW is very nice as I don’t have to manually add/remove users from the Front End PM groups.
June 23, 2021 at 9:32 pm #43251Shamim HasanKeymasterAdd following code in your theme’s (child theme’s if you are using) functions.php.
add_filter( 'fep_get_option', function( $value, $option ){ if( 'can-send-to-group' == $option ){ if( array_intersect( [ 'administrator', 'rolename' ], wp_get_current_user()->roles ) ){ $value = true; } else { $value = false; } } return $value; }, 10, 2 );
after that user with administrator and rolename (you can change to your actual role name) role can send message without being a member.
June 24, 2021 at 12:16 am #43253wayne.schulzParticipantYes, I have done that using code from post #28661 (replaced ‘teacher’ with ‘manager’ and added ‘administration’).
This is what one of the users in the ‘administration’ role sees:
[✓] Send Message to group
[All Drivers ˅ ]
[All Employees]
[Administrative]This user is also in the ‘drivers’ role and of course the ’employee’ role, however, this user being in the ‘administration’ role should also see all the other groups and is not. (see attached)
I require managers and administration to be able to send to any group (or a select set of groups) even if not a member of. I do not wish to make a ‘manager’ or an ‘administration’ user a member of all the other groups.
Attachments:You must be logged in to view attached files.June 24, 2021 at 12:26 am #43256Shamim HasanKeymasterSorry for the confusion. Please remove those code and follow https://www.shamimsplugins.com/support/topic/latest-update-breaks-groups/#post-26896 (return conditionally if user in your desire role)
June 24, 2021 at 4:35 am #43258wayne.schulzParticipantThis reply has been marked as private.June 24, 2021 at 4:02 pm #43262Shamim HasanKeymasterPlease change to following
// Allow administrator and manager group to send to other groups add_filter( 'fep_filter_groups_to_send_message', function( $groups ){ if( array_intersect( [ 'administrator', 'administration', 'manager' ], wp_get_current_user()->roles ) ){ return Fep_Group_Message::init()->get_all_groups(); } return $groups; });
Also with your last added code except these 3 roles nobody will be allowed to send a group message.
June 25, 2021 at 6:38 pm #43266wayne.schulzParticipantI see the code above was an attempt to combine the two functions I had, however, it did not work. No one was able to send to any groups.
June 27, 2021 at 8:12 am #43271Shamim HasanKeymasterCan you please send me all code added for this plugin?
June 28, 2021 at 7:18 pm #43274wayne.schulzParticipantAll code added for your plugin was posted in reply #43258,
I replaced all below ‘// Allow administrator and manager group to send to other groups’ with your code above (reply #43262).
When that did not work, I reverted back to what was posted in reply #43258 (which is working).
June 29, 2021 at 12:26 pm #43282Shamim HasanKeymasterWhat code you have now will allow all users to send message to any group. and except that 3 roles nobody will allowed to send to any group.
If that is ok then you can continue.
Or you can use #43262 code again (i changed a bit there) and remove your last filter.
Let me know -
AuthorPosts
You need to purchase ‘Front End PM PRO’ to create topic in this support forum.
If you already purchased ‘Front End PM PRO’ please LOGIN.