camyen
asked 9 years ago

Hello there,

How can I turn ‘x wrote a new post’ into ‘x posted a new question’ on BP activity stream? I tried the code below in my child theme’s function.php

<?php
class PJW_Translation_Mangler {
function filter_gettext($translation, $text, $domain) {
$translations = &get_translations_for_domain( $domain );
if ( $text == '%s wrote a new post, %s' ) {
return $translations->translate( '%s asked a new question, %s' );
}
return $translation;
}
}
add_filter('gettext', array('PJW_Translation_Mangler', 'filter_gettext'), 10, 4);
?>

When I refreshed the wp-admin page, a syntax error message (on line 21, the first line of your code above) was shown on the top.

Any idea?

Best

2 Answers
DominicStaff
answered 9 years ago

About your code it will not work. I think you can change in the following file:

#: bp-blogs/bp-blogs-activity.php:182
 "%1$s wrote a new post, %2$s, on the site %3$s"

#: bp-blogs/bp-blogs-activity.php:184
 "%1$s wrote a new post, %2$s"

Hope this helps !

camyen
replied 9 years ago

With the code above, my activity stream is showing something like this: x posted a new post answer xxx question

Any idea?

camyen
replied 9 years ago

I’d like something like these:
x posted a new question
x answered a question/ x posted a answer

x followed a question.

camyen
replied 9 years ago

@Dominic
Is it possible to do so?

nobita
replied 9 years ago

Im not sure that you have buddypress integrate with dwqa or not, if you have it , you can go to file buddypress/function.php and find this function : dw_simplex_record_question_activity()

In side there find the line :$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>' );

Change it to : $activity_action = sprintf( __( '%s posted a new question: %s', 'dw-simplex' ), bp_core_get_userlink( $user_id ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>' );

some thing like that ? because i’m not sure what u really want ? well i think it could be a lot easier for me to have a look at your theme folder or the function.php file in buddypress . It’ll be nice if you send us your account via private answer.

camyen
replied 9 years ago

According to the BP Integration Guide from yours, the function is in my_child_theme/buddypress/bp-custom.php, not in buddypress/function.php

camyen
answered 9 years ago

@nobita

Yes, I’ve integrated BP and DWQA. Please take a look at the screenshots attached with this message.

What I want to do is: 1.replace ‘wrote a new post’ with ‘answered a question’. 2. remove ‘Answer for’.

I’ve tried your code and Dominic’s, but nothing was changed.

Any idea? (sorry, I’m not able to give you the admin access.)

nobita
replied 9 years ago

@camyen ; hi about problem 1 , i think Dominic guide should work , you can try open the plugin file :wp-content/plugins/buddypress/bp-blogs/bp-blog-activity.php and go to line 181 and 185 , change the word there :

if ( is_multisite() ) {
        $action  = sprintf( __( '%1$s answered a question, %2$s, on the site %3$s', 'buddypress' ), $user_link, $post_link, '<a href="' . esc_url( $blog_url ) . '">' . esc_html( $blog_name ) . '</a>' );
    } else {
        $action  = sprintf( __( '%1$s answered a question, %2$s', 'buddypress' ), $user_link, $post_link );
    }

and about the 2nd’s problem , you can go to wp-content/plugin/dw-question-answer/inc/actions.php go to line 80
and change the code to :

$answer_title = $question->post_title;

( remove the " __( 'Answer for ', 'dwqa' ) " )
Well that is what i think of, because i didn’t see any picture attached, so sorry about that. hope this help.

camyen
replied 9 years ago

Perfect. It works. I think problem 2 is solved. There is a extended problem generated from problem 1. ‘Answered a question’ is different from ‘ asked a question’. The code above uses to modify bp-blog-activity.php did not clarify these two. Any idea?

nobita
replied 9 years ago

well yes, in problem 1 , i think you want to change that in blog activity record. Can you send me the picture of it , i think i need to know where you want to replace.

camyen
replied 9 years ago

How can I send a screenshot in hype link?

nobita
replied 9 years ago

@camyen : hi you can upload the picture to http://imgur.com/ and then post the link here i think

Powered by DW Question & Answer Pro