• *Issue seems to affect both pro and free version of the plugin*

    When Mentioning @user, in the event that the user set their email address as the username, the feature does not work.

    My suspicion is that the @ symbol being called as part of the email address breaks the functionality.

    This is a huge problem for my use case because nearly all my users are created and imported from my sister site and their username is set to their email automatically.

    Would it be possible (maybe even just as a pro feature) to have an option in the plugin to set your own qualifying symbol to run the “mentions” feature?

    Here is a quick example I drafted up to visually display what I mean:

    https://snipboard.io/b5noKu.jpg

    In this example I would have changed the identifier symbol to * instead of @

    This is just one simple way to resolve the issue that would also add value to the pro version!

    Or if there is a simpler way to allow email addresses that would be fine too

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Bunty

    (@bhargavbhandari90)

    Thanks for reporting this and your suggestion. I will do the necessary.

    Plugin Author Bunty

    (@bhargavbhandari90)

    @evanhgh Can you update the plugin and let me know if this works or not.

    Thread Starter evanhgh

    (@evanhgh)

    Hi Bunty,

    Unfortunately, this is still an issue.

    If a user has an “@” symbol in their username it is not possible to mention them.

    Thread Starter evanhgh

    (@evanhgh)

    The problem seems to be how the plugin is parsing usernames. It’s assuming that usernames are simple alphanumeric strings, and thus it’s interpreting any “@” sign as the beginning of a mention. If a username has an “@” sign in it (as in an email address), it incorrectly breaks the mention.

    Could we solve this problem by changing the username pattern that we match when searching for mentions. Instead of treating every “@” sign as the start of a mention, we could first check if it’s not already part of an email address?

    Specifically, in the class-comment-mention.php file

    public static function cmt_mntn_find_mentions( $content ) {
    
    $pattern = '/[@]+([A-Za-z0-9-_\.@]+)\b/';
    		preg_match_all( $pattern, $content, $usernames );
    
    //rest of code

    to

    public static function cmt_mntn_find_mentions( $content ) {
    
        // Do not consider email addresses as mentions
        $pattern = '/(?<![A-Za-z0-9-_.])[.@]([A-Za-z0-9-_\.@]+)\b/';
        preg_match_all( $pattern, $content, $usernames );
    
        // rest of code
    
    

    This change to the regular expression MIGHT ensure that an “@” character isn’t treated as a mention if it’s preceded by an alphanumeric character, hyphen, underscore, or period – (the valid characters in an email username)

    the addition of this negative-lookbehind-assertion would be more precise because it tries to exclude matches that are part of an email address. This is useful when trying to ignore email addresses when searching for “mentions” and only want to capture instances where usernames are mentioned with a preceding @ symbol.

    I have not familiarized myself with the rest of the code so this could very well break it more. no idea.

    EDIT:
    Nevermind that didnt work in my staging site, please ignore the suggestion lol

    • This reply was modified 1 year, 6 months ago by evanhgh.
    Thread Starter evanhgh

    (@evanhgh)

    Hey just checking in, have we made any progress on the issue of mentioning users with emails as their username?

    Plugin Author Jay Patel

    (@hackkzy404)

    Hey, @evanhgh

    It seems working for me, can you please provide screenshots and which theme you’re using so that I can try to replicate this issue.

    As you can see I can mention users with username set as email

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Bug – Users that set their Email Address as username break funcitonality’ is closed to new replies.