Skip to content
Advertisement

User ID remove @ and transform “.” into “-“

I have this function in order to set a link for my user to go to their custom profile page :

JavaScript

The issue is that if the user ID is his email like john@example.com the link https://mywebsite/author/john@example.com will have an 403 error. But if the is the link is https://mywebsite/author/johnexample-com it works.

So is there a way to clean the user ID into my function in order to remove @ and transform “.” into “-” ?

Best regards, Clément

Advertisement

Answer

Try this

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement