Mostofa Ahmed
asked 10 years ago

How to get a solution about DW Q&A Integration in Buddypress Activity Stream like yours?
Thanks in advance.

5 Answers
DominicStaff
answered 10 years ago

Hi Mostofa !
Of course, I can show you how we did it, please follow instruction below:
 
Step 1: Install BuddyPress plugin.
Step 2: Go to your theme folder (wp-content/themes/[theme-name]), and create a new folder, named it “buddypress”. Inside your new folder, create a new file: “bp-custom.php”
 
Now, open up the new file in notepad or any code editor, and copy/paste the code at this link : http://snippi.com/s/e4s59cg
 
Note: Please change ‘dw_simplex’ & ‘dw-simplex’ to your theme name
Step 3: Open the function file of your theme (wp-content/themes/[theme-name]/functions.php), and add this code in (somewhere at top of the file):

 include_once get_template_directory().'/buddypress/bp-custom.php';

Final step: Save the files and go to your profile page to see list of all questions on the new Questions tab.
 
Hope that helps!

Mostofa Ahmed
replied 10 years ago

Not working for me 🙁

Dom Amor
replied 10 years ago

What is not working ?. Works great for me and on a genesis framework.

Semion Bourakevich
replied 10 years ago

Hi, i’ve made all the changes and i see questions on profie page, but three right boxes are not displayed. Can you suggest why? 🙂 http://dumbnumb.com/

Müller
replied 10 years ago

doesn’t work 🙁 did it step by step but nothing happens on the user page

Jackie Lord
replied 10 years ago

@sembur : Please update DW Question & Answer to latest version. The sidebar will be back. You can read about the changes here: http://cmspioneer.com/designwall/blog/dw-question-answer-wordpress-plugin-version-1-1-1-spam-free-and-the-return-of-sidebar/

@Muller : Can you comment your website URL for further checking

Mike
replied 10 years ago

I am using iThemes ‘Builder’ with ‘air’ child theme. Where would I upload the buddypress folder?

themes/Builder
OR
themes/Builder-Air-Custom

and when I rename the template in the file what should I use as the template instead of dw_simplex

Regards
Mike

Guru
replied 10 years ago

already replied in the other question

elvin_huseynov
replied 8 years ago

It did not work for me

dominic Staff
replied 8 years ago

Please create a new question and let me know detail about your issue, I have checked your link and it not works. Please check it and include in your question. I will remove it in this question.

Dom Amor
answered 10 years ago

I have this implemented and works well, thank you. However if I click on a users name, author page comes up. Like  mydomain.com/author/username. Is there a to change this as well ?

Mostofa Ahmed
answered 10 years ago

Finally i did it. now the Question list shows on the user profile. but while user click on answer button an error occurred.
Fatal error: Call to undefined function bp_blogs_record_activity() in /home/………/public_html/blog/wp-content/themes/dw-minion/buddypress/bp-custom.php on line 110
Please tell me how to fix it??

Dom Amor
replied 10 years ago

Did you change anything on in the Q&A templates. Got a link ?

Mostofa Ahmed
replied 10 years ago

Thanks for reply. No, i didn’t change anything on Q&A.

Mostofa Ahmed
replied 10 years ago

Hey, Site Tracking was turned off on BP component. Now it’s okey. Fixed. Thanks again.

lifeischoice
replied 10 years ago

@askmediy: I am trying to get to work as well on a genesis child theme (dynamiks)…unfortunately, nothing related shows…any help which line to add the dynamik name?

Dom Amor
replied 10 years ago

Place the buddypress folder that you made in the Genesis theme directory. Not the active theme but the core theme of Genesis.

lifeischoice
replied 10 years ago

Thank you very much…that worked in placing “Question” in the menu tab, but not adding the 3 boxes below the profile image…your assistance is much appreciated

Dom Amor
answered 10 years ago

I would double check all your code and make sure that you have your active theme set right in the code that these guys gave us. All of mine works fine.

lifeischoice
replied 10 years ago

Thanks again…the only part I want to confirm is whether to change all the dw_simplex and dw-simplex in the file at bp-custom.php to Genesis or Dynamik-Gen

Dom Amor
replied 10 years ago

Yes of course.

lifeischoice
replied 10 years ago

Would that change be to Genesis or Dynamik-Gen
Thanks again….

Dom Amor
replied 10 years ago

Your active theme. I don’t know Dynamik-Gen. Share that with me and I’ll what I can do with it. email it to me [email protected] if you want.

DominicStaff
answered 10 years ago

@ Dom ! Thanks for your help. I appreciate it !
@Debo !
I have checked your site, and look like it is working very well. If you want to display Question tab have style as our demo, You can open the bp-custom.php file, replace all the code in the bp-custom.php  file with new code:

 <?php
if ( function_exists('dwqa_plugin_init') && function_exists('bp_is_active')) {
  /*-----------------------------------------------------------------------------------*/
  /*  Setup Questions in BuddyPress User Profile
  /*-----------------------------------------------------------------------------------*/
  add_action( 'bp_setup_nav', 'dw_simplex_bp_nav_adder' );
  function dw_simplex_bp_nav_adder() {
     bp_core_new_nav_item(
      array(
        'name' => __('Questions', 'dw-simplex'),
        'slug' => 'questions',
        'position' => 21,
        'show_for_displayed_user' => true,
        'screen_function' => 'questions_list',
        'item_css_id' => 'questions',
        'default_subnav_slug' => 'public'
      ));
  }

  function questions_list() {
    add_action( 'bp_template_content', 'profile_questions_loop' );
    bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
  }

  function profile_questions_loop() {
    global $dwqa_options;
    $submit_question_link = get_permalink( $dwqa_options['pages']['submit-question'] );
    $questions = get_posts(  array(
      'posts_per_page' => -1,
      'author'         => bp_displayed_user_id(),
      'post_type'      => 'dwqa-question'
    ));
    if( ! empty($questions) ) { ?>
      <div class="dwqa-container">
        <div class="dwqa-list-question">
          <div class="dw-question" id="archive-question">
            <?php foreach ($questions as $q) { ?>
            <article id="question-18267" class="dwqa-question">
                <header class="dwqa-header">
                    <a class="dwqa-title" href="<?php echo get_post_permalink($q->ID); ?>" title="Permalink to <?php echo $q->post_title ?>" rel="bookmark"><?php echo $q->post_title ?></a>
                    <div class="dwqa-meta">
                        <?php dwqa_question_print_status($q->ID); ?>
                        <span><?php echo get_the_time( 'M d, Y, g:i a', $q->ID ); ?></span>
                        &nbsp;&nbsp;&bull;&nbsp;&nbsp;
                        <?php echo get_the_term_list( $q->ID, 'dwqa-question_category', '<span>Category: ', ', ', '</span>' ); ?>
                    </div>
                </header>
            </article>
            <?php } ?>
          </div>
        </div>
      </div>
    <?php } else { ?>
    <div class="info" id="message">
      <?php if( get_current_user_id() == bp_displayed_user_id() ) : ?>
        Why don't you have question for us. <a href="<?php echo $submit_question_link ?>">Start asking</a>!
      <?php else : ?>
        <p><strong><?php bp_displayed_user_fullname(); ?></strong> has not asked any question.</p>
      <?php endif; ?>
    </div>
    <?php }
  }

  /*-----------------------------------------------------------------------------------*/
  /*  Record Activities
  /*-----------------------------------------------------------------------------------*/
  // Question
  function dw_simplex_record_question_activity( $post_id ) {
    $post = get_post($post_id);
    if(($post->post_status != 'publish') && ($post->post_status != 'private'))
      return;

    $user_id = get_current_user_id();
    $post_permalink = get_permalink( $post_id );
    $post_title = get_the_title( $post_id );
    $activity_action = sprintf( __( '%s asked a new question: %s', 'dw-simplex' ), bp_core_get_userlink( $user_id ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>' );
    $content = $post->post_content;
    $hide_sitewide = ($post->post_status == 'private') ? true : false;

    bp_blogs_record_activity( array(
      'user_id' => $user_id,
      'action' => $activity_action,
      'content' => $content,
      'primary_link' => $post_permalink,
      'type' => 'new_blog_post',
      'item_id' => 0,
      'secondary_item_id' => $post_id,
      'recorded_time' => $post->post_date_gmt,
      'hide_sitewide' => $hide_sitewide,
    ));
  }
  add_action( 'dwqa_add_question', 'dw_simplex_record_question_activity');

  //Answer
  function dw_simplex_record_answer_activity( $post_id ) {
    $post = get_post($post_id);

    if($post->post_status != 'publish')
      return;

    $user_id = $post->post_author;

    $question_id = get_post_meta( $post_id, '_question', true );
    $question = get_post( $question_id );

    $post_permalink = get_permalink($question_id);
    $activity_action = sprintf( __( '%s answered the question: %s', 'dw-simplex' ), bp_core_get_userlink( $user_id ), '<a href="' . $post_permalink . '">' . $question->post_title . '</a>' );
    $content = $post->post_content;

    $hide_sitewide = ($question->post_status == 'private') ? true : false;

    bp_blogs_record_activity( array(
      'user_id' => $user_id,
      'action' => $activity_action,
      'content' => $content,
      'primary_link' => $post_permalink,
      'type' => 'new_blog_post',
      'item_id' => 0,
      'secondary_item_id' => $post_id,
      'recorded_time' => $post->post_date_gmt,
      'hide_sitewide' => $hide_sitewide,
    ));
  }
  add_action( 'dwqa_add_answer', 'dw_simplex_record_answer_activity');
  add_action( 'dwqa_update_answer', 'dw_simplex_record_answer_activity');

  //Comment
  function dw_simplex_record_comment_activity( $comment_id ) {
    $comment = get_comment($comment_id);
    $user_id = get_current_user_id();
    $post_id = $comment->comment_post_ID;
    $content = $comment->comment_content;

    if(get_post_type($post_id) == 'dwqa-question') {
      $post = get_post( $post_id );
      $post_permalink = get_permalink( $post_id );
      $activity_action = sprintf( __( '%s commented on the question: %s', 'dw-simplex' ), bp_core_get_userlink( $user_id ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>' );
      $hide_sitewide = ($post->post_status == 'private') ? true : false;
    } else {
      $post = get_post( $post_id );
      $question_id = get_post_meta( $post_id, '_question', true );
      $question = get_post( $question_id );
      $post_permalink = get_permalink( $question_id );
      $activity_action = sprintf( __( '%s commented on the answer at: %s', 'dw-simplex' ), bp_core_get_userlink( $user_id ), '<a href="' . $post_permalink . '">' . $question->post_title . '</a>' );
      $hide_sitewide = ($question->post_status == 'private') ? true : false;
    }

    bp_blogs_record_activity( array(
      'user_id' => $user_id,
      'action' => $activity_action,
      'content' => $content,
      'primary_link' => $post_permalink,
      'type' => 'new_blog_comment',
      'item_id' => 0,
      'secondary_item_id' => $comment_id,
      'recorded_time' => $comment->comment_date_gmt,
      'hide_sitewide' => $hide_sitewide,
    ));
  }
  add_action( 'dwqa_add_comment', 'dw_simplex_record_comment_activity');
}

Hope this helps !

Mike
replied 10 years ago

I would just like to add the following:
If you want the DW Q&A authors and answerers links to point to their buddypress profile download and install the BP Blog Author Profile Link plugin – http://wordpress.org/plugins/bp-blog-author-link/
Because questions and answers are actually posts this works well. Also works for comments.
I am not sure if that would affect the coding above?
Regards
Mike

Xioux D'Oughnymme
replied 10 years ago

For me this is broken, look, at the top of the page is the include text, strange! what did I do wrong?
http://54.68.138.238/question/does-this-work

Kishore Sahoo
answered 9 years ago

Here is a Ext. You may like it.
BuddyPress Question Answer: Q&A System For BuddyPress Sites http://shop.opentuteplus.com/product/buddypress-question-answer/

Akhil Srivastava
answered 2 years ago

Hi, i tried to use your solution, now its started showing in activity stream but there is one issue. in activity stream its says user  “wrote a new post” instead of saying user “asked a new question” same with answer, when someone post comment, again it says, commented on the post

Powered by DW Question & Answer Pro