• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Creating/Using PHP Callback

#1
Hi everyone,
I want to create a costum user field that must be include user's mobile phone number like +901234567890, but I'm not sure how to create/use php callback.

May the below php code be help?

PHP:
<?php

function gsm($text) {
    $text  = preg_replace("/[^0-9]/", "", $text);
    $first = substr("$text",0,1);
    if($first == "0") { $text = substr($text,1); }

    $ninety = substr("$text",0,2);
    if($ninety != "90") {
        $new_gsm = "Invalid: Not TR's country code."; }
    else {
        $gsm = substr($text,2);
        if(substr("$gsm",0,1) == "0") {
            $gsm = substr($gsm,1); }

        if(strlen($gsm) != "10") {
            $new_gsm = "Invalid: Must be in this format (901112223344)"; }
        else {
            $new_gsm = "+$ninety$gsm"; }
    }

    return $new_gsm;
}

?>