Apologies for not explaining more clearly.
My site will not be using members real names, members will be allowed to choose a nickname (Smiley101, for example) hence the reason I need to implement something to stop them from using the same display name (the name that they are allowed to change in their profile).
I only want to display their nickname across the entire site, because using both the username ( used to log into site/wordpress} and display name /nickname is confusing my members.
My original idea was have members use the username to login and have the display name/ nickname display across the entire site.
I tried both of the code you suggested, they are returning an error (Parse error: syntax error, unexpected ‘function’ (T_FUNCTION) in /home…)
Thank you for taking the time to help me.