• Welcome to the Chevereto user community!

    Here users from all over the world gather around to learn the latest about Chevereto and contribute with ideas to improve the software.

    Please keep in mind:

    • 😌 This community is user driven. Be polite with other users.
    • 👉 Is required to purchase a Chevereto license to participate in this community (doesn't apply to Pre-sales).
    • 💸 Purchase a Pro Subscription to get access to active software support and faster ticket response times.
  • Chevereto Support CLST

    Support response

    Support checklist

Hyphen (-) implemented in user names?

Gambalunga

💖 Chevereto Fan
I previously asked a question in the Support forum about implementing hyphen (-) in user names. I have now modified a little code to achieve this.

Line 186 in \app\lib\classes\class.settings.php has been modified as follows to include the "-" (hyphen) character in the user names pattern.
Code:
'username_pattern'           => '^[\w-]{3,16}$',// - added after w

I then modified the two files where I found the tool tip:
Line 40 (comment line 41) in /app/themes/Peafowl/views/signup.php
Code:
<input type="text" name="username" id="signup-username" class="text-input" autocomplete="off" value="<?php echo get_safe_post()["username"]; ?>" pattern="<?php echo CHV\getSetting('username_pattern'); ?>" rel="tooltip" title='<?php _se('%i to %f characters<br>Letters, numbers, "-" and "_"', ['%i' => CHV\getSetting('username_min_length'), '%f' => CHV\getSetting('username_max_length')]); ?>' data-tipTip="right" placeholder="<?php _se('Username'); ?>" required>
                   <?php /* tooltip modified to include "-" */?>
And
Line in 144 in /app/themes/Peafowl/views/settings.php
Code:
<input type="text" name="username" id="username" maxlength="<?php echo CHV\getSetting('username_max_length'); ?>" class="text-input" value="<?php echo get_safe_post() ? get_safe_post()["username"] : get_user()["username"]; ?>" pattern="<?php echo CHV\getSetting('username_pattern'); ?>" rel="tooltip" title='<?php _se('%i to %f characters<br>Letters, numbers, "-" and "_"', ['%i' => CHV\getSetting('username_min_length'), '%f' => CHV\getSetting('username_max_length')]); ?>' data-tipTip="right" placeholder="<?php _se('Username'); ?>" required>

Note in both cases the words
Letters, numbers and "_"
have been modified to
Letters, numbers, "-" and "_"
 
Many thanks for reviewing this, will take a look :)

We have a significant number of people who use hypens in their usernames, whereas we have no one with underscores, consequently it could very useful.
 
Underscore (_) is considered a word character for \w regex but a hyphen isn't. This means that user_name is a word while user-name are two different words.

Here https://blog.codinghorror.com/of-spaces-underscores-and-dashes/

So we want those to be crawled as "user_name" or as "user"+"name"? To be honest, I don't know what is better but I think that it won't matter anyway.
 
Underscore (_) is considered a word character for \w regex but a hyphen isn't. This means that user_name is a word while user-name are two different words.

Here https://blog.codinghorror.com/of-spaces-underscores-and-dashes/

So we want those to be crawled as "user_name" or as "user"+"name"? To be honest, I don't know what is better but I think that it won't matter anyway.
Thanks for the explanation.

I now understand that the hyphen is not in the \w regex but I must say that I can not agree that it is not included. Having done a little research on the internet I can see that the lack of a hyphen causes a lot of problems in the Anglo-Saxon world. The very name "Anglo-Saxon" is a typical example of a hyphenated name and the hyphen is often used to join two words. It is also common to have hyphenated family names such as Smyth-Jones in the British tradition and the hyphen is sometimes used in other traditions. The underscore character is never used to join two names and as far as I can see it is only in the /w regex because a space was, in the past, not acceptable in file names etc. and the underscore was allowed as a substitute for the space. In the Spanish and Portuguese tradition a space between double (or more) family names is more common.

Unfortunately I suspect that the decision not to include the hyphen was one made by a committee and, as often happens with committee decisions, it has failed to meet the requirements of a fair proportion of users.

I, for one, am not worried about whether or not Google sees a user-name as two different words and will continue to add the hyphen character to the permitted user names. I agree with you and can't see that, in this case, it makes any difference and I doubt you would get any complaints if you decided to implement it in the standard script.
 
Update
Following recent updates to the Chevereto script the exact line numbers mentioned in the original post have changed. Following the advice in the documentation at https://chevereto.com/docs/theme I have copied my modified theme files (updated to the latest version) to /app/themes/Peafowl/overrides

The two files concerned are:
/app/themes/Peafowl/views/signup.php
and
/app/themes/Peafowl/views/settings.php

I'm not sure if the modified \app\lib\classes\class.settings.php will be read in overrides (I have also put a copy there) and I don't have time to experiment at the moment. I guess I will find out with the next update :D
 
Back
Top