How can I provide a checkbox to display name as 'anonymous'? When users register on my website, they have to fill in their name. However, not everyone wants his/her name to be displayed on his/her profile page. Therefore, I'd like to provide a checkbox "Show as anonymous" during the registration which changes the name to anonymous on the profile page. In other words, the checkbox rewrites the displayed name, as opposed to Is there a way to let every user can choose (e.g. on registration) whether their field is private or public?, where the field is hidden.

I rewrote the profile pages with user_view in the Pages section and I'm using Panels.

How can I do that?
You can add one more text field to user entity, keep it hidden.While registering the user check if show as anonymous user field is checked save the hidden field value as anonymous else copy the user name field to hidden field.

You can do the above changes in hook_user_presave().

Finally add this hidden field to your user view, instead of name field.