2012-04-17 65 views
0

我使用buddypress主题[buddyboss](http://buddyboss.com/)。主要原因是这个主题能够管理图片库(这很好用)。我需要更改buddypress主题(wordpress)中的函数

我现在想要在members-loop中调用该图片函数。在buddyboss-管理员的人告诉我:

“,您将需要从buddy_boss_pics.php功能具体来说,你需要使用的功能buddyboss_pics_screen_picture_grid_content()从行开始:285你需要编辑文件工作与成员循环,因为它目前使用displayed_user_id。“

这是函数的样子:

function buddyboss_pics_screen_picture_grid_content() 
{ 
    global $bp, $wpdb, $bbpics; 

    $wpdb->show_errors = BUDDY_BOSS_DEBUG; 

    $img_size = is_active_sidebar('Profile') ? 'buddyboss_pic_med' : 'buddyboss_pic_wide'; 

    $gallery_class = is_active_sidebar('Profile') ? 'gallery has-sidebar' : 'gallery'; 

    $user_id = $bp->displayed_user->id; 
    $activity_table = $wpdb->prefix."bp_activity"; 
    $activity_meta_table = $wpdb->prefix."bp_activity_meta"; 

    $pages_sql = "SELECT COUNT(*) FROM $activity_table a INNER JOIN $activity_meta_table am ON a.id = am.activity_id WHERE a.user_id = $user_id AND meta_key = 'bboss_pics_aid'"; 

    $bbpics->grid_num_pics = $wpdb->get_var($pages_sql); 

    $bbpics->grid_current_page = isset($_GET['page']) ? (int) $_GET['page'] : 1; 

    // Prepare a SQL query to retrieve the activity posts 
    // that have pictures associated with them 
    $sql = "SELECT a.*, am.meta_value FROM $activity_table a INNER JOIN $activity_meta_table am ON a.id = am.activity_id WHERE a.user_id = $user_id AND meta_key = 'bboss_pics_aid' ORDER BY a.date_recorded DESC"; 

    buddy_boss_log("SQL: $sql"); 

    $pics = $wpdb->get_results($sql,ARRAY_A); 

    $bbpics->grid_pagination = new BuddyBoss_Paginated($pics, $bbpics->grid_pics_per_page, $bbpics->grid_current_page); 

    buddy_boss_log("RESULT: $pics"); 

    // If we have results let's print out a simple grid 
    if (!empty($pics)) 
    { 
     $bbpics->grid_had_pics = true; 
     $bbpics->grid_num_pics = count($pics); 

任何帮助将是巨大的,因为我真的需要做到这一点!

+0

你可能会得到http://wordpress.stackexchange.com/答案。 – fuxia 2012-04-17 08:32:48

回答

0

Untested-但试试这个:

在成员循环,寻找

   <?php 
      /*** 
       * If you want to show specific profile fields here you can, 
       * but it'll add an extra query for each member in the loop 
       * (only one regadless of the number of fields you show): 
       * 
       * bp_member_profile_data('field=the field name'); 
       */ 
      ?> 

结束PHP标签>

   buddyboss_pics_members_loop(bp_get_member_user_id()); 

复制buddyboss_pics_screen_picture_grid_content()函数之前添加呢?到成员循环的底部。

把它的PHP标签之间并更改名称 buddyboss_pics_members_loop($ user_ID的)

和注释掉或删除 $ USER_ID = $ BP-> displayed_user-> ID;

+0

嘿..你的描述似乎很清楚,但它不起作用!?!?事情是:图片网格不显示,而是所有其他用户消失...该死的 – 2012-04-19 13:42:49

+0

我上传了两个示例文件..也许你可以告诉我如何做到这一点... ... http:// ge.tt/3uWNXYG/v/0?c – 2012-04-19 14:22:27

0

这里的buddyboss_pics_screen_picture_grid_content()函数主要使用user_id并从数据库中获取图像。

简单,你也打电话成员loop.php文件while循环中的函数: buddyboss_pics_screen_picture_grid_content(bp_member_user_id())

这里通过这个函数的参数member_user_id。

小编辑低于主buddyboss_pics_screen_picture_grid_content()功能:

以下变化:

function buddyboss_pics_screen_picture_grid_content($user_id = null) 
{ 

    //Remove this code 
    $user_id = $bp->displayed_user->id; 

    //Put new Code 
    if (empty($user_id)) { 
     $user_id = $bp->displayed_user->id; 
    } else { 
     $user_id = $user_id; 
    } 

}