Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Youzify - BuddyPress Mention User On Reply
<?php
/**
* Youzify - BuddyPress Mention User On Reply
*/
add_action( 'wp_footer', 'yzc_mention_user_on_reply' );
function yzc_mention_user_on_reply() {
?>
<script type="text/javascript">
( function( $ ) {
$( document ).ready( function() {
$( '.activity' ).on( 'click', '.acomment-reply', function() {
let li = $( this ).closest( 'li' );
let user_link = li.find( '.acomment-meta a' ).attr( 'href' ).replace(/\/$/, "");
let username = user_link.substring(user_link.lastIndexOf('/') + 1);
setTimeout( function() {
let form = li.find( 'form' );
li.find( 'textarea' ).val( '@' + username + ' ' );
form.find( '.youzify-emojionearea-editor' ).html( '@' + username + ' ' );
}, 50 );
});
});
})( jQuery );
</script>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment