Group Mods

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

Modifying @mention link output and adding @mention to post-form.php’s $content before $_post (6 posts)

Started 1 year, 1 month ago by: msullens88

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

    Ok, so this has turned into a two part question.

    1. In my users activity feed (modified to show both @mentions, status updates, photos from bp-gallery etc) it shows guest posts as follows “@marty hey hows it going” — My Goal is to elinimate the @username and I’ve successfully done this with css by adding “Display: none;” on my “div.activity_data p a:first-child” style selector.

    As you can see this has obvious flaws, it hides any first link in the activity feed data, and its hiding my 1st photo on activity updates made by BP-Gallery.

    So, what I am trying to do, is add a (id=”remove_mention”) to the link that is generated by buddypress for the @mention so I can hide it.

    The closest thing I could find was in (bp-activitybp-activity-filters.php) but had no luck modifying it to include this “id=remove_mention” I could only get it to add the id to all posts.

    2. I have the post-form.php working correctly on profiles that are not the logged in users and am able to leave @mentions but having to manually type in the @mention before the message then post.

    I would like to include the displayed users mention id to the forms data before being posted, (e.g what I’m doing now “@marty hey hows it going?” would like to type “hey hows it going” and have the @marty attached before posting much like on this site here.

    Any help would be greatly appreciated, these are the last two major things I need to overcome before finishing up this site.

  • @msullens88 How did you combine @mentions, status updates, photos from bp-gallery into one activity feed? I have been looking for the answer to this for weeks. I have an activity feed on a users profile, but can’t get @mentions to show.

    Your help would be greatly appreciated!

    Thanks

    -Paul

  • Oh, I have an answer to your question number 2 above:

    I duplicated the post-form, renamed it and call the new form just above their activity. Below is the code for the new form php file

    <form action="<?php bp_activity_post_form_action() ?>" method="post" id="whats-new-form" name="whats-new-form">
    
    	<?php do_action( 'bp_before_activity_post_form' ) ?>
    
    	<?php if ( isset( $_GET['r'] ) ) : ?>
    		<div id="message" class="info">
    			<p><?php printf( __( 'You are mentioning %s in a new update, this user will be sent a notification of your message.', 'buddypress' ), bp_get_mentioned_user_display_name( $_GET['r'] ) ) ?></p>
    		</div>
    	<?php endif; ?>
    
    	<div id="whats-new-avatar">
    		<a href="<?php echo bp_loggedin_user_domain() ?>">
    			<?php bp_loggedin_user_avatar( 'width=' . BP_AVATAR_THUMB_WIDTH . '&height=' . BP_AVATAR_THUMB_HEIGHT ) ?>
    		</a>
    	</div>
    
    	<h5>
    		<?php printf( __( "Say Something To %s", 'buddypress' ), bp_get_user_firstname() ) ?>
    
    	</h5>
    
    	<div id="whats-new-content">
    
    		<div id="whats-new-textarea">
    			<textarea name="whatsnew" id="whats-new" cols="50" rows="10" onClick="ta(); this.form.whatsnew.value= '@<?php bp_displayed_user_username() ?> ';" title="Do not Erase &quot;@<?php bp_displayed_user_username() ?>&quot;"><?php if ( isset( $_GET['r'] ) ) : ?>@<?php echo esc_attr( $_GET['r'] ) ?> <?php endif; ?></textarea>
    		</div>
    <center><small>This is a PUBLIC message</small></center>
    		<div id="whats-new-options">
    			<div id="whats-new-submit">
    				<span class="ajax-loader"></span> &nbsp;
    				<input type="submit" name="aw-whats-new-submit" onClick="at();"id="aw-whats-new-submit" value="<?php _e( 'Post Message', 'buddypress' ) ?>" />
    			</div>
    
    			<?php do_action( 'bp_activity_post_form_options' ) ?>
    
    		</div><!-- #whats-new-options -->
    	</div><!-- #whats-new-content -->
    
    	<?php wp_nonce_field( 'post_update', '_wpnonce_post_update' ); ?>
    	<?php do_action( 'bp_after_activity_post_form' ) ?>
    
    </form><!-- #whats-new-form -->

    and here is the js for the function calls:

    function ta() {
    document.getElementById("whats-new").style.height = "60px";
    }
    function at() {
    document.getElementById("whats-new").style.height = "20px";
    }
  • Profile picture of msullens88 msullens88 said 1 year, 1 month ago:

    @embergermedia

    This is how I got the mentions in the profile activity feed.

    Edit the file bp-activity-classes.php in the buddypress plugin folder.

    function get_filter_sql( $filter_array ) {
    		global $wpdb;
    
    		if ( !empty( $filter_array['user_id'] ) ) {
    $user_filter = explode( ',', $filter_array['user_id'] );
    $user_sql = " ( a.user_id IN ( " . $filter_array['user_id'] . " ) ";
    foreach ( $user_filter as $user_id ) {
    $search_terms = '@' . bp_core_get_username( $user_id ) . '<';
    $user_sql .= "OR ( a.content LIKE '%%".like_escape($search_terms)."%%' ) ";
    }
    $user_sql .= " ) ";
    $filter_sql[] = $user_sql;
    }

    and replace this first top half of the function, No need to edit past the first “if” part of that function.

    Hope this helps!

  • @msullens88

    Thanks- I stumbled across that the other day. I wish it weren’t a core change. Guess we can’t have it all.

    Be well

  • Profile picture of abyss abysshorror said 5 months, 2 weeks ago:

    Where should I add the js functions ? I think the modifications are working without them anyway :)

    I had to change some variables in order to get the right nicenames (@username). Thanks for the code !