Skip to content

Instantly share code, notes, and snippets.

@KaineLabs
Last active April 10, 2023 16:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KaineLabs/e6a309e5728495d96cac89a5f4818eba to your computer and use it in GitHub Desktop.
Save KaineLabs/e6a309e5728495d96cac89a5f4818eba to your computer and use it in GitHub Desktop.
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-options .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
}
@vasudevz
Copy link

Hi....
I just wanted to bring to your notice that it does not work on mobile. At least this is the case with my site. When a user clicks on the comment option on the post, the page refreshes and after that, if a user clicks once again, it works. And this is when I use the basic Hello Elementor theme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment