Skip to:
Content
Pages
Categories
Search
Top
Bottom

A custom feature I wish I found how to do


  • keshabee
    Participant

    @keshabee

    2)I wanted to ask if there was a function code that could print a word such as Website associate to display beside, users profile photo in the profile page when given a certain role.

    3) Finally wanted to ask if it was possible to have a function where a green light dot is placed at side of a user profile page when the user is logged in, an example is
    https://postimg.org/image/ym0tuaoy3/
    as presently its grey there because the user is offline.

    Thanks you

Viewing 4 replies - 1 through 4 (of 4 total)

  • Venutius
    Moderator

    @venutius

    Regarding 2) a while back Henry passed me this code snippet to go into functions.php in your child theme. I think it could be modified to deliver what you are looking for:

    function keshabee_display_member_role() {
        global $members_template;
        // This is a confirmed group member.
        if ( $members_template->member->is_confirmed )
            echo '<p>Member</p>';
        // This is a group moderator.
        if ( $members_template->member->is_mod )
            echo '<p>Group Mod</p>';
        // This is a group admin.
        if ( $members_template->member->is_admin )
            echo '<p>Admin</p>';
    }
    add_action( 'bp_group_members_list_item_action', 'keshabee_display_member_role' );

    keshabee
    Participant

    @keshabee

    Thank you very much @venutius
    It works


    Venutius
    Moderator

    @venutius

    That’s great, thinking about it this should go in your bp-custom.php, then you won’t need to remember to transfer it if you ever change your theme. Or as a rather nifty way of managing code snippets you could use:

    Code Snippets


    Venutius
    Moderator

    @venutius

    Regarding point 3, I have discovered one way to do this.

    You would need to overload the members-header.php (if not using cover images) or cover-image-header.php file, located in plugins/buddypress/bp-templates/bp-legacy/buddypress/members/single

    Copy this file to themes/YOURTHEME/buddypress/members/single

    Then after line 36 insert the following:

    <div id="online">
        <?php
        global $bp;
        function check_is_user_online($user_id){
            if ( bp_has_members( 'type=online&include='.$user_id) ) return true;
            else return false;
        }
        $this_id = bp_displayed_user_id();
        $is_online = check_is_user_online($this_id);
        if ($is_online) echo "<label><img src='http://yourserver.com/wp-content/uploads/online.png' /> Online</Label>";
        else{ echo "<label><img src='http://http:yourserver.com/wp-content/uploads//offline.jpg' /> Offline</label>";}
        ?>
    </div>

    Replace the URL’s for the images to your own links and that should work, you can style it using the id #online

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Skip to toolbar