Group Mods

  • Profile picture of @mercime
  • Profile picture of r-a-y
  • Profile picture of Hugo

Change Reply button on activty stream posting for Forums! (12 posts)

Started 1 year, 1 month ago by: skateage

  • Profile picture of skateage skateage said 1 year, 1 month ago:

    Hey Buddypress!

    Im interested in changing the reply button for forum posts on the activity stream listing. Instead of having the “reply” button it would have a “View Post” button that would take you to the permalink of the forum post. Im not sure how difficult a task like this would be but i dont have the experience to figure it out by my lonesome.

    so…. instead of this:
    http://img641.imageshack.us/img641/199/replyn.gif

    It would say this:
    http://img842.imageshack.us/img842/8449/reply2.gif

    and take you here: http://www.skateage.com/groups/skateboarders/forum/topic/the-berrics-or-the-fantasy-factory/#post-140

    If someone has a solution or is willing to find one i would be thrilled to the point of explosion.

  • Profile picture of skateage skateage said 1 year ago:

    bump

  • Profile picture of Brandon Allen Brandon Allen said 1 year ago:

    In your theme’s activity/entry.php file change:

    <?php if ( is_user_logged_in() && bp_activity_can_comment() ) : ?>
         <a href="<?php bp_activity_comment_link() ?>" class="acomment-reply" id="acomment-comment-<?php bp_activity_id() ?>"><?php _e( 'Reply', 'buddypress' ) ?> (<span><?php bp_activity_comment_count() ?></span>)</a>
    <?php endif; ?>

    to:

    <?php if ( is_user_logged_in() && bp_activity_can_comment() ) : ?>
         if ( my_bp_activity_type_is_new_forum_post() ) {
              <a href="<?php bp_activity_thread_permalink(); ?>" class="acomment-reply" id="acomment-comment-<?php bp_activity_id() ?>"><?php _e( 'View Post', 'buddypress' ) ?></a>
         } else {
              <a href="<?php bp_activity_comment_link() ?>" class="acomment-reply" id="acomment-comment-<?php bp_activity_id() ?>"><?php _e( 'Reply', 'buddypress' ) ?> (<span><?php bp_activity_comment_count() ?></span>)</a>
         }
    <?php endif; ?>

    and add the following to your theme’s functions.php file:

    function my_bp_activity_type_is_new_forum_post() {
         ( 'new_forum_post' == bp_get_activity_type() ) ? return true : return false;
    }
  • Profile picture of James James said 1 year ago:

    hi @cnorris23 ,

    tried to implement your changes, result is (for functions.php):

    Parse error: syntax error, unexpected T_RETURN

  • Profile picture of josemv josemv said 1 year ago:

    I have the following code in my bp-custom.php file

    function my_bp_activity_entry_meta() {
    
    	if ( bp_get_activity_object_name() == 'blogs' && bp_get_activity_type() == 'new_blog_post' ) {?>
    		<a class="view-post" href="<?php bp_activity_thread_permalink() ?>">Ver nuevo post</a>
    	<?php }
    
    	if ( bp_get_activity_object_name() == 'blogs' && bp_get_activity_type() == 'new_blog_comment' ) {?>
    		<a class="view-post" href="<?php bp_activity_thread_permalink() ?>">Ver comentario</a>
    	<?php }
    
    	if ( bp_get_activity_object_name() == 'activity' && bp_get_activity_type() == 'activity_update' ) {?>
    		<a class="view-post" href="<?php bp_activity_thread_permalink() ?>">Ver actualizacion</a>
    	<?php } 
    
            if ( bp_get_activity_object_name() == 'groups' && bp_get_activity_type() == 'new_forum_topic' ) {?>
    		<a class="view-thread" href="<?php bp_activity_thread_permalink() ?>">Ver hilo en el foro</a>
    	<?php } 
    
            if ( bp_get_activity_object_name() == 'groups' && bp_get_activity_type() == 'new_forum_post' ) {?>
    	    <a class="view-post" href="<?php bp_activity_thread_permalink() ?>">Ver respuesta en el foro</a>
    	<?php }
    
    }
    add_action('bp_activity_entry_meta', 'my_bp_activity_entry_meta');

    Trim what you don’t need. Mine is translated to spanish also

  • Profile picture of James James said 1 year ago:

    thanks @el_terko ,

    it works, but do you know how to remove reply button for certain activities and change order of meta buttons. At the moment view button stands 4 in a row?

  • Profile picture of josemv josemv said 1 year ago:

    Gee, afraid not, I am just a cut-and-paster
    Maybe use the above code as a place to start from

  • Profile picture of Brandon Allen Brandon Allen said 1 year ago:

    @janismo Yep. I see the problem. Sorry about that. It’s a lot harder to catch your mistakes when you’re not using a dedicated code editor ;) Try this instead.

    <?php if ( is_user_logged_in() && bp_activity_can_comment() ) : ?>
         <php if ( my_bp_activity_type_is_new_forum_post() ) : ?>
              <a href="<?php bp_activity_thread_permalink(); ?>" class="acomment-reply" id="acomment-comment-<?php bp_activity_id() ?>"><?php _e( 'View Post', 'buddypress' ) ?></a>
         <php else : ?>
              <a href="<?php bp_activity_comment_link() ?>" class="acomment-reply" id="acomment-comment-<?php bp_activity_id() ?>"><?php _e( 'Reply', 'buddypress' ) ?> (<span><?php bp_activity_comment_count() ?></span>)</a>
         <php endif; ?>
    <?php endif; ?>
  • Profile picture of James James said 1 year ago:

    @el_terko ,

    if I put only code from your last post, it adds “view” button to all activities, which acts 100% like “reply” button (hides/reveals text box).
    if additionally I put your function from previous post, then I get “Parse error: syntax error, unexpected T_RETURN” again :)

    actually, I thought it will be another copy/past work. if it takes lots of time, no need to bother about.

    thanks!

  • Profile picture of Brandon Allen Brandon Allen said 1 year ago:

    I think that was a javascript issue. It thought it was still a normal reply. Give the code below a shot.

    <?php if ( is_user_logged_in() && bp_activity_can_comment() ) : ?>
         <php if ( my_bp_activity_type_is_new_forum_post() ) : ?>
              <a href="<?php bp_activity_thread_permalink(); ?>" class="acomment-view" id="acomment-comment-<?php bp_activity_id() ?>"><?php _e( 'View Post', 'buddypress' ) ?></a>
         <php else : ?>
              <a href="<?php bp_activity_comment_link() ?>" class="acomment-reply" id="acomment-comment-<?php bp_activity_id() ?>"><?php _e( 'Reply', 'buddypress' ) ?> (<span><?php bp_activity_comment_count() ?></span>)</a>
         <php endif; ?>
    <?php endif; ?>
  • Profile picture of James James said 1 year ago:

    @el_terko

    ok, latest news from fighting field:
    last code in itself adds working “view” button to every activity, reply buttons still are there.
    function my_bp_activity_type_is_new_forum_post() still returns same error.

    Edit: no need to proceed with this question, I will use code by josemv. thanks again

  • Profile picture of Brandon Allen Brandon Allen said 1 year ago:

    For anyone else with this question, the following code should work:

    <?php if ( is_user_logged_in() && bp_activity_can_comment() ) : ?>
         <php if ( my_bp_activity_type_is_new_forum_post() ) : ?>
              <a href="<?php bp_activity_thread_permalink(); ?>" class="acomment-view" id="acomment-comment-<?php bp_activity_id() ?>"><?php _e( 'View Post', 'buddypress' ) ?></a>
         <php else : ?>
              <a href="<?php bp_activity_comment_link() ?>" class="acomment-reply" id="acomment-comment-<?php bp_activity_id() ?>"><?php _e( 'Reply', 'buddypress' ) ?> (<span><?php bp_activity_comment_count() ?></span>)</a>
         <php endif; ?>
    <?php endif; ?>
    
    function my_bp_activity_type_is_new_forum_post() {
         if ( 'new_forum_post' == bp_get_activity_type() )
              return true;
    
         return false;
    }