Difference between revisions of "Custom Transliteration"
Line 1: | Line 1: | ||
− | Transliteration is the practice of converting | + | ==Transliteration in WHMCS== |
+ | Transliteration is the practice of converting text from one writing system into another in a systematic way. | ||
− | + | You can use this with WHMCS to automatically replace characters in client profile data that third-party systems may reject. For example, a domain registrar's API might automatically reject certain characters in received requests. | |
− | + | ==Custom Transliteration Function== | |
+ | WHMCS includes a default function to find and replace the most common special characters that cause problems. If you need to tailor this to your unique needs, you can define a <tt>hook_transliterate</tt> function in the <tt>/includes/hooks/</tt> directory. This will override the default function and allow you to specify your own character replacements. | ||
− | + | <div class="source-cli"> | |
− | + | <?php | |
− | + | </br> | |
− | + | </br>function hook_transliterate($string) { | |
− | + | </br> $string = str_replace("ž","z",$string); | |
− | + | </br> $string = str_replace("é","e",$string); | |
− | + | </br> return $string; | |
− | + | </br>} | |
− | + | </br> | |
+ | </br>?> | ||
+ | </div> | ||
− | + | Copy-and-paste the code above into a new file and save it in the <tt>/includes/hooks/</tt> directory. Then, you can customise the character replacements. You must specifically define this as the <tt>hook_transliterate</tt> function. | |
+ | |||
+ | To use this, return the converted string at the end of the call. You do not need to use the <tt>add_hook</tt> function with this feature. |
Revision as of 21:01, 27 May 2020
Transliteration in WHMCS
Transliteration is the practice of converting text from one writing system into another in a systematic way.
You can use this with WHMCS to automatically replace characters in client profile data that third-party systems may reject. For example, a domain registrar's API might automatically reject certain characters in received requests.
Custom Transliteration Function
WHMCS includes a default function to find and replace the most common special characters that cause problems. If you need to tailor this to your unique needs, you can define a hook_transliterate function in the /includes/hooks/ directory. This will override the default function and allow you to specify your own character replacements.
<?php </br> </br>function hook_transliterate($string) { </br> $string = str_replace("ž","z",$string); </br> $string = str_replace("é","e",$string); </br> return $string; </br>} </br> </br>?>
Copy-and-paste the code above into a new file and save it in the /includes/hooks/ directory. Then, you can customise the character replacements. You must specifically define this as the hook_transliterate function.
To use this, return the converted string at the end of the call. You do not need to use the add_hook function with this feature.