Skip to:
Content
Pages
Categories
Search
Top
Bottom

Group directory


  • monchib
    Participant

    @monchibord

    Hi, I would like to know how to add “created by ‘id user’ ” to the title of every group in the Groups Directory Page.
    Is there a way to that? I can’t undestand which code i have to edit.
    Should I create a custom php file?
    Thanks in advance for your support,
    Simo

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

  • @mercime
    Keymaster

    @mercime

    The one who creates the group is the Group Admin. So the easiest way to set up what you want would be to copy bp-default theme’s group-header.php file from https://buddypress.trac.wordpress.org/browser/tags/1.5.5/bp-themes/bp-default/groups/single/group-header.php into your child theme folder following the directory structure.

    Open up group-header.php and change
    `

    `
    to
    `

    `
    and save file.


    monchib
    Participant

    @monchibord

    Thank you so much. I’ll follow your advice, but this is the Group header when you are already in the group page. What if I want to display the “Created by” after the Group title in the Group directory?


    monchib
    Participant

    @monchibord

    Ok I understood I have to create the file “goups-loop.php” in my child theme. I succeed to add text and other lil things, but when I try to add “created by” and the user id of the group admin or his avatar, I get: “Created by: no admin” Can anyone help me? Which code should I use to get group admin name or avatar?
    I also tried to add this code in “goups-loop.php”:

    But it gives me error. If I change “creator_id” with any other Class it works perfectly (id; name; slug; description; status;….).
    Thanks in advance

    @monchibord

    That’s a slightly different question than the opening post suggested, but you can try something like this (doubtless there are better approaches)

    `
    // Somewhere before the groups loop ‘while’
    <?php
    global $groups_template;
    $group_detail = $groups_template;
    ?>
    // In your group loop li element somewhere you can do

    Created By: <a href="group->creator_id) ?>”> $group_detail->group->creator_id , ‘width’ => 80, ‘height’ =>80))?>

    `
    I’ll leave you to work out how to fetch the members name :)

    edit// for completeness I’ll add – although it was really a lesson for the class – the name
    `group->creator_id) ?>`

    It’s actually a useful little snippet and could do with being turned into a function to use in groups loop and single group screens


    monchib
    Participant

    @monchibord

    thank you Hugo, I hope I did exactly what you said and now I see Created by:
    It doesn’t get the avatar or name…. :(
    This is the code. I’m really sorry to bother you and I really appreciate your help.
    `<?php

    /**
    * BuddyPress – Groups Loop
    *
    * Querystring is set via AJAX in _inc/ajax.php – bp_dtheme_object_filter()
    *
    * @package BuddyPress
    * @subpackage bp-default
    */

    ?>
    global $groups_template;
    $group_detail = $groups_template;

    • <a href="”>

      <a href="”>

      Created By: <a href="group->creator_id) ?>”> $group_detail->group->creator_id , ‘width’ => 80, ‘height’ =>80))?>

      /

    `

    You need to move the global and variable to after the `if(bp_has_groups(bp_ajax_querystring( ‘groups’ ) ) ) :` line as that sets groups in motion


    monchib
    Participant

    @monchibord

    @Hugo
    Done…but still nothing after “created by”
    Seriously, I can’t understand what’s wrong. :(
    Thank you

    sorry nor can I, it works for me – can’t see what may be going wrong for you.


    valuser
    Participant

    @valuser

    try
    `<?php
    global $groups_template;
    $group_detail = $groups_template;
    ?>`

    Now How to get the avatar to the right of Created by: ???

    tried
    `ul#groups-list.item-list li img.avatar {
    margin- left: 100px;
    }’

    but it shoves the whole lot to the right.

    Thanks for this tip in any event

    @valuser thanks, good spot missed that lack of php tags completely assumed they would be added :)

    @monchibord you need to add php tags around those first two lines – sorry I made the assumption they would get added.

    @valuser sounds as though you have styles conflicting if you are calling BP default styles then you need to kill the float:left on avatars so add a new class to that avatar ? ‘group-creator’ or better still add that as an id to the paragraph tag or whatever tag wraps the text and anchor and amongst other styles add ` #group-creator img.avatar {float: none;}` but you may need to play around a bit to find the right rules to override.


    monchib
    Participant

    @monchibord

    @valuser @Hugo
    Guys, I don’t know how to thank you. :)


    valuser
    Participant

    @valuser

    Many thanks @Hugo.

    `

    `
    and
    #group-creator img.avatar {float: none; margin-top: 2px;}

    appears to work for me.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Group directory’ is closed to new replies.
Skip to toolbar