Viewing 15 replies - 1 through 15 (of 16 total)
  • Thread Starter AleksDerFar

    (@aleksderfar)

    I’ve been looking and it isn’t difficult adding a class and icon or image into display.php

    Is there any way to display that image or icon in the left side (before) of username?

    Plugin Author Andrew Breksa

    (@abreksa4)

    That’s exactly what I’m working on at the moment. If you’d like to contribute, the code is hosted on GitHub: https://github.com/abreksa4/bbp-user-online-status

    Activate WP Dashicons on frontend:

    // Load WP Dashicons at the front
    add_action( 'wp_enqueue_scripts', 'themename_scripts' );
    function themename_scripts() {
        wp_enqueue_style( 'themename-style', get_stylesheet_uri(), array( 'dashicons' ), '1.0' );
    }

    And use in your plugin code:

    add_action('bbp_theme_after_reply_author_details', 'bbp_user_online_status');
    function bbp_user_online_status(){
        global $bbpuos_options;
        echo '<ul>';
        $user_id = bbp_get_reply_author_id($reply_id);
        if ($bbpuos_options['activate'] == true) {
            echo '<li>';
            if (is_user_online($user_id)) {
                echo "Online: <span class=\"online dashicons dashicons-chart-bar\"></span>";
            } else {
                echo "Offline: <span class=\"offline dashicons dashicons-chart-bar\"></span>";
            }
            echo '</li>';
        }
    }

    Some simple CSS:

    .online.dashicons.dashicons-chart-bar {color: #31AF40;}
    .offline.dashicons.dashicons-chart-bar {color: #CF1A1D;}

    Plugin Author Andrew Breksa

    (@abreksa4)

    Thanks! Have you had a chance to test it?

    Or better to use just Dashicons icon without text (choose one icon that fits best) and hook into reply header:

    add_action('bbp_theme_before_reply_admin_links', 'bbp_user_online_status');
    function bbp_user_online_status(){
        global $bbpuos_options;
        echo '<div class="offline-online-wrapper">';
        $user_id = bbp_get_reply_author_id($reply_id);
        if ($bbpuos_options['activate'] == true) {
    
            if (is_user_online($user_id)) {
                echo "<span class=\"online dashicons dashicons-chart-bar\"></span>";
            } else {
                echo "<span class=\"offline dashicons dashicons-chart-bar\"></span>";
            }
            echo '</div>';
        }
    }

    Some CSS to begin with:

    .offline-online-wrapper {float:left; display:inline-block; margin:0 10px 0 0; padding:0;}

    Yes Andrew, i just tested it.
    here is a bit more for profile and members lists. For BuddyPress but seasy to adapt to bbPress only:

    https://bbpress.org/forums/topic/display-this-plugin-before-the-username-on-replies/

    Plugin Author Andrew Breksa

    (@abreksa4)

    Thanks again, I’ll see if I can get it integrated. You’re welcome to fork the plugin on Github (https://github.com/abreksa4/bbp-user-online-status) and make a pull request with your changes.

    This on that URL is not exactly fo your plugin. Only for inspiration. Unless you find all necessary hooks. This involves editing template files.

    I will check it later. If you will implement this looks better to use reply header (left of reply date/time).

    If someone can hook to before date/time write it here. I could not find it. So to not use float:left. I hate this, just makes headaches.

    Plugin Author Andrew Breksa

    (@abreksa4)

    I agree, the current layout is just a proof of concept, the end goal is to have the configurable icons next to author names across the entire forum, and configurable location for the topic/reply view.

    In regard to my previous post about the Github repo, I as referring to the modified plugin code you posted above.

    Plugin Author Andrew Breksa

    (@abreksa4)

    Looking at the bbpress function reference here: http://etivite.com/api-hooks/#bbpress

    Specifically http://etivite.com/api-hooks/bbpress/component/bbp-themes/

    If you will use icons only better to use mouseover tooltip with explanation for both icons:

    title=\”User is Online\”
    title=\”User is Offline\”

    add_action('bbp_theme_before_reply_admin_links', 'bbp_user_online_status');
    function bbp_user_online_status(){
        global $bbpuos_options;
        echo '<div class="offline-online-wrapper">';
        $user_id = bbp_get_reply_author_id($reply_id);
        if ($bbpuos_options['activate'] == true) {
    
            if (is_user_online($user_id)) {
                echo "<span class=\"online dashicons dashicons-chart-bar\" title=\"User is Online\"></span>";
            } else {
                echo "<span class=\"offline dashicons dashicons-chart-bar\" title=\"User is Offline\"></span>";
            }
            echo '</div>';
        }
    }

    And this works better, different apostrophe. More natural.

    if (is_user_online($user_id)) {
                echo '<span class="online dashicons dashicons-chart-bar" title="User is Online"></span>';
            } else {
                echo '<span class="offline dashicons dashicons-chart-bar" title="User is Offline"></span>';
    Thread Starter AleksDerFar

    (@aleksderfar)

    I’m sorry I’ve been offline several days but luckily Lee is here.

    Since I’m having problems with dashicons in Firefox I did the same with font awesome icons.

    Lee code edited:

    if (is_user_online($user_id)) {
                echo '<span class="user-status-online fa fa-user" title="Online"></span>';
            } else {
                echo '<span class="user-status-offline fa fa-user" title="Offline"> </span>';
    .user-status-online.fa.fa-user {color: #0ab40a;}
    .user-status-offline.fa.fa-user {color: #a00a0a;}

    Image examble

    Plugin Author Andrew Breksa

    (@abreksa4)

    Thanks guys for all the help. I’ve got a big push for work to get taken care of, but I should get this up and running this weekend.

    Stagger Lee

    (@stagger-lee)

    Aleks, image example indicates it is not working for you ?

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Show a red / green circle?’ is closed to new replies.