• Resolved af3

    (@af3)


    Hi,
    How do I auto add all users with role=administrator as chat participants?
    I saw FEP_Participants::init()->insert( $mgs_id, $participant_ids ) but do not know where should I add this.

    Thanks

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Shamim Hasan

    (@shamim51)

    you can add following code in your theme’s (child theme’s if you are using) functions.php

    add_action( 'fep_action_message_after_send', function( $mgs_id ){
        $admins = array( 1,2,3 );  //your admin IDs as array
        FEP_Participants::init()->insert( $mgs_id, $admins );
    });
    
    Thread Starter af3

    (@af3)

    Thanks @shamim51 — this works well. The only issue now is that the new participants do not see the message in the Inbox (front-end), they can click on the back-end to get to the message but it doesnt appear in the inbox list.

    Plugin Author Shamim Hasan

    (@shamim51)

    It is working from me. They should have received all messages in their Messagebox (front-end).

    Make sure you have added admin user ids there instead of 1,2,3

    Thread Starter af3

    (@af3)

    Yup, its working for new messages, but not for replied messages… will check again.
    the admin userids are correct and not 1,2,3 🙂

    Plugin Author Shamim Hasan

    (@shamim51)

    Message (New message) sent after this code added will work for reply also.
    If message sent before this code added may not work for reply.

    Thread Starter af3

    (@af3)

    Thanks Shamim. I added these in functions.php around line 793, it works ok now.

    
    if ( $can ) {
    	$participants = FEP_Participants::init()->get( $id );
    	foreach ( $participants as $participant ) {
    	// never false for admin
           	if ( $participant->mgs_deleted  && !fep_is_user_admin() ) {
    		$can = false;
    		break;
    		}
    	// never false for admin
           	if ( ! fep_is_user_whitelisted() && fep_is_user_blocked_for_user( $participant->mgs_participant ) && !fep_is_user_admin() ) {
    		$can = false;
    		break;
    		}
            }
    }
    • This reply was modified 4 years, 11 months ago by af3.
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Auto add users with admin role to chat participants’ is closed to new replies.