*

mysterdee

  • *
  • 3 posts
Relocate Online Chat Plugin ( Send Message Box )
« on: September 25, 2025, 11:10:25 PM »
Hi, im very new to osclass but not to PHP, im familure with PHP. However using the plugins manually and customising them is a little difficult depending on the plugin itself.

i know how to manually place a plugin at specific locations thats fine , but in this case i do tis abut then the origonal " Send Message " Button is still being displayed

I am hoping maybe somebody who is familure with the online Chat Plugin would be ableto to help me..


I would prefer to actually just move ther origonal and have it displayed at another location, but just adding the if exists call within another div, just results in 2 buttons being displayed and the new button doesnt actually do anything



here is how i am placing the Button where i need on the item page... And also the FUNCTION.PHP for the Online chat button ( Make )

i would like to know how do i remove the origonal button.

thanks in advance for any replies




WHERE I AM ADDING THE BUTTON

        <h2>
          <?php _e('', 'delta'); ?>
          <?php if(osc_item_user_id() > 0) { ?>
            <a href="#about" class="hbtn"><?php _e('Contact', 'delta'); ?></a>
           
            <span><?php if(function_exists('oc_chat_button')) { echo oc_chat_button(); } ?></span>
           
           
          <?php } ?>
        </h2>




THIS IS THE MAKE BUTTON FUNCTION.PHP FOR ONLINE MESSAGES PLUGIN




function oc_chat_button( $user_id = '' ) {
  $html = '';
  $user_name = '';

  if((osc_is_ad_page() || osc_is_search_page()) && $user_id == '') {
    $user_id = osc_item_user_id();
    $user_name = osc_item_contact_name();
  }

  if($user_id <> '' && $user_id > 0) {
    $registered = 1;
    $last_active = ModelOC::newInstance()->getUserLastActive($user_id);

    $active_limit = osc_get_preference('refresh_user', 'plugin-online_chat');
    $active_limit = ($active_limit > 0 ? $active_limit : 120);
    $active_limit = $active_limit + 10;

    $limit_datetime = date('Y-m-d H:i:s', strtotime(' -' . $active_limit . ' seconds', time()));
  } else {
    $registered = 0;
  }

  if($registered == 1 && $user_id <> osc_logged_user_id() && !oc_check_bans($user_id)) {
    $class = ' oc-active';
  } else {
    $class = ' oc-disabled';
  }

  if(isset($limit_datetime) && $limit_datetime <> '' && $last_active >= $limit_datetime) {
    $class .= ' oc-online';
  } else {
    $class .= ' oc-offline';
  }

  $html .= '<a href="#" class="oc-chat-button' . $class . '" data-to-user-id="' . $user_id . '" data-to-user-name="' . osc_esc_html($user_name) . '" data-to-user-image="' . oc_get_picture( $user_id ) . '">';
  $html .= '<div class="oc-user-left"><i class="fa fa-comments-o"></i></div>';

  $html .= '<div class="oc-user-right">';

  if($registered == 0) {
    $html .= '<div class="oc-user-top">' . __('Chat unavailable', 'online_chat') . '</div>';
    $html .= '<div class="oc-user-bot">' . __('User is not registered', 'online_chat') . '</div>';
  } else {
    if($user_id == osc_logged_user_id()) {
      $html .= '<div class="oc-user-top">' . __('Chat unavailable', 'online_chat') . '</div>';
      $html .= '<div class="oc-user-bot">' . __('It is your listing', 'online_chat') . '</div>';
    } else if (oc_check_bans($user_id)) {
      $html .= '<div class="oc-user-top">' . __('Chat unavailable', 'online_chat') . '</div>';
      $html .= '<div class="oc-user-bot">' . __('User has blocked you', 'online_chat') . '</div>';
    } else {
      $html .= '<div class="oc-user-top oc-status-offline">' . __('Send a Message', 'online_chat') . '</div>';
      $html .= '<div class="oc-user-bot oc-status-offline">' . __('User is offline', 'online_chat') . '</div>';

      $html .= '<div class="oc-user-top oc-status-online">' . __('Start chatting', 'online_chat') . '</div>';
      $html .= '<div class="oc-user-bot oc-status-online">' . __('User is online', 'online_chat') . '</div>';
    }
  }

  $html .= '</div>';
  $html .= '</a>';

  return $html;
}



My question again is. How do i Manually Locate the Button whilst removing the origonal thats located in the hook
« Last Edit: September 25, 2025, 11:36:45 PM by mysterdee »

*

mysterdee

  • *
  • 3 posts
Re: Relocate Online Chat Plugin ( Send Message Box )
« Reply #1 on: September 26, 2025, 12:08:37 AM »
OK. so figured this out myself after a little brainstorming.

There is an option to Hook Initiate Chat Button

This Enables "Button will be automatically hooked to item page (using item_detail hook) and no theme modifications are required."

Turning this off means that the Button will not be displayed without Manually adding the Hook yourself. Therfore granting you the possibility to locate wherever you wish the button to be located.

Thank you for any responds.


*

MB Themes

Re: Relocate Online Chat Plugin ( Send Message Box )
« Reply #2 on: October 01, 2025, 08:41:01 AM »
@mysterdee
That is correct way, you can disable hook and place it where you prefer it.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots