Last active
April 10, 2023 16:05
-
-
Save KaineLabs/e6a309e5728495d96cac89a5f4818eba to your computer and use it in GitHub Desktop.
Youzify - BuddyPress Mention User On Reply
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.