Support » Plugins » Hacks » Need help with "Javascript chat for wordpress" plugin

  • Hi

    I just started using the “Javascript chat for wordpress” plugin, and it’s just what I need, but there is just one thing that annoys me:

    When people write it shows their login-name and not their display-name. Can anyone help me change this? I think it’s in the function below that some changes are needed:

    function postMessage()
    {
    global $wpdb;
    global $current_user;
    $options = get_option($this->adminOptionsName);
    $excludes = preg_split(‘@\s*,\s*@’, $options[‘exclude_ips’]);
    if($options[‘enabled’]!=’false’ && !in_array($_SERVER[‘REMOTE_ADDR’], $excludes))
    {
    require_once (ABSPATH . WPINC . ‘/pluggable.php’);
    get_currentuserinfo();

    $pseudo = ”;
    $user_ip = $_SERVER[‘REMOTE_ADDR’];

    if(isset($current_user->user_login) && !empty($current_user->user_login))
    {
    $pseudo = $current_user->user_login;
    }
    else
    {
    $options = get_option($this->userPseudoOptions);
    if(isset($options) && isset($options[$user_ip]))
    $pseudo = $options[$user_ip];
    else
    {
    $alea = rand(0,9999);
    $pseudo = ‘anonym’.$alea;
    $options[$user_ip] = $pseudo;
    update_option($this->userPseudoOptions, $options);
    }
    }

    $table_name = $wpdb->prefix.’jschat_messages’;
    $table_canal_name = $wpdb->prefix.’jschat_canal’;
    $wp_jschat_text = $_POST[‘wp_jschat_text’];
    $submit = $_POST[‘wp_jschat_submit’];
    $query = $wpdb->prepare(“SELECT * FROM $table_canal_name WHERE id=’%s'”,$_POST[‘wp_jschat_canal’]);
    $canal = $wpdb->get_results($query);
    $channel = (count($canal))? $_POST[‘wp_jschat_canal’] : ‘1’;

    if(isset($submit) && trim($wp_jschat_text)!=”)
    {
    $wpdb->insert($table_name, array(
    ‘id_user’ => $current_user->ID,
    ‘pseudo’ => $pseudo,
    ‘message’ => strip_tags(trim($wp_jschat_text)),
    ‘created_at’ => current_time(‘mysql’),
    ‘canal’ => $channel,
    ‘ip’ => $_SERVER[‘REMOTE_ADDR’]
    ));
    }
    }
    die();
    }
    /**
    * Affichage du panneau d’administration du chat
    * @global wpdb $wpdb
    */

Viewing 2 replies - 1 through 2 (of 2 total)
  • The modification that you will need to do is as below,

    Original
    if(isset($current_user->user_login) && !empty($current_user->user_login))
    {
    $pseudo = $current_user->user_login;

    Modified
    if(isset($current_user->display_name) && !empty($current_user->display_name))
    {
    $pseudo = $current_user->display_name;

    Basically just got to replace user_login to display_name, hope that solves your question.

    Thread Starter Anqders25

    (@anqders25)

    Thank you very much Endlestine! I’ll try that.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Need help with "Javascript chat for wordpress" plugin’ is closed to new replies.