Chat Plugin: Does it support chats with unregistered users (for sales inquiries)?

Can you please tell me whether the chat plugin can initiate chats from someone who is not a registered user of WP, i.e., a visitor to the site who has a sales inquiry? If so, how would I go about requesting a first name, last name, and email addy before opening a chat session? Thanks!

  • Vinod Dalvi

    Hi Andy,

    Welcome to the WPMU Dev community and thank you for your question.

    Yes you can achieve this by just selecting the option Public Users in the "Other Login Options" settings from the following path that would allow anyone to chat with you without logging in.

    Admin Area -> Chat -> Settings Site -> Authentication

    It would still ask your users to enter their Name and email address to enable posting messages, these users are not stored anywhere. The name and email address are just used for the chat session. The email is used to get a user's gravatar and uniquely identify the user.

    Find more information about it in the following reply.

    https://premium.wpmudev.org/forums/topic/how-to-add-chat-to-specific-pages-for-non-registered-users#post-789608

    Please advise if you have more questions.

    Best Regards,
    Vinod Dalvi

    • Andy

      Thank you for you timely response to my question, Vinod.

      I have set up the chat plugin and have been able to format it using the plugin UI to a level where I am reasonably happy with its appearance. I have five quick follow up questions:

      1. In the case of the authentication of public users, would it be possible to save the name and the email address in a db somewhere? This would help with tracking sales inquiries.

      2. is it possible for us to validate the email address, including a specific type of domain suffix (.io for example)?

      3. Is it possible to set all chat requests from public users to a private chat? Our business is quite sensitive in nature and the thought of having a second unrelated public user enter an existing chat is not an acceptable proposition for us.

      4. Before entering the chat, is it possible for a moderator to accept the chat request (in a similar fashion as in private chat)?

      5. Finally, can you please point me in the direction of where I might go in the code to further customize the look and feel of the chat client, email form, and system messages to users of the plugin?

      Thanks again.

      Andy

  • Milan

    Hello @Andy,

    I hope you are doing good..

    Here are solutions..

    1) Yes, it is possible. for this you need to change some of the core files of plugin.
    First of all you need to create one table inside database where you can store user's information.
    to create table in existing wordpress database just follow these steps.. https://codex.wordpress.org/Creating_Tables_with_Plugins#Creating_or_Updating_the_Table

    after you have table you can use this table to insert user information to database. how you can insert those data to database that is explained in above article in depth.

    Now you need a source which gives you public user email and name when they try to first logged in.
    User information will be available to you when chat_user_login function of /wp-content/plugins/wordpress-chat/wordpress-chat.php file will be called by our plugin's ajax mechanism. (Check Line no: 5291)

    Don't worry too much about how this function will be called. This function is the point where you can add database insertion logic to add public user information to db.

    as you can see in first attachment $user_info = $_POST['user_info']; will return you array of public user information who is trying to logged in.

    You can get name and email from that array.. here is sample code how I would like to do.

    $user_info = $_POST['user_info'];
    
    $user_info['name']  = esc_attr( $user_info['name'] );
    $user_info['email'] = esc_attr( $user_info['email'] );
    
    //Tada.. Got what you wanted.. now just use these information to add data to db.
    
    //use your function in place of "addPublicUserInfoToDb"
    addPublicUserInfoToDb( $user_info['name'], $user_info['email'] );

    Finally you can query user information table to get how many user quired for sales inquiry.

    2) Sure this is possible. As in my first answer I told you how you can grab user information, you can pass user email to php function is_email( $userEmial ). This function will return true if user provided email is valid..

    3) You want to use private chat functionality in public chat which is not possible now.

    4) No, I am sorry but this is not possible.

    5) markup of Login form of public user you can modify in /wp-content/plugins/wordpress-chat/wordpress-chat.php file in which markup is rendered using chat_login_public function.

    Many of customization options are provided by plugin itself. see second attachment for more detail. But if you still want to modify core structure of chat client you can change its structure in process_chat_shortcode functions of /wp-content/plugins/wordpress-chat/wordpress-chat.php file.

    This is the function which is responsible for rendering chat shortcode. This the place from where you can modify look and feel of client.

    Notes:
    1) Please note that modifying core html structure of chat client may stops plugin works properly. because whole chat plugin uses predefined html structure to process each request. you can confirm this by looking at /wp-content/plugins/wordpress-chat/js/wpmudev-chat.js file.
    2) Again most of customization you can do just by tweaking setting provided by plugin it self.
    3) Last but not the least you can use css to customize look and feel.

    Hope this helps you.

    Regards.
    Milan Savaliya
    Support Staff( WPMUDEV )