back to phpList.org

Format attributes


#1

I have attributes like cell phone, main phone, etc.
I would like to have them formated as they are entered (or stored) to fit the U.S. format like so… (555) 555-1212
Is there a way to do this ?
I am good with html, and fair with php.

using phplist version 3.3.1
PHP 5.6.34
MySQL 5.7.21


#2

@johntrot You should be able to reformat an attribute value by developing a plugin. It needs only to implement one method validateSubscriptionPage(), which can transform $_POST in some way. The method is called when a subscribe page is being displayed (which is probably an error) or submitted. Here is an example supposing that 3 is the id of the attribute that you want to alter .

public function validateSubscriptionPage($pageData)
{
    if (!$_POST) {
        return '';
    }
    var_dump($_POST);

    if (isset($_POST['attribute3'])) {
        // transform $_POST['attribute3'] in some way
        // $_POST['attribute3'] = $newValue;
    }

    return '';
}

There is more information about developing plugins here https://resources.phplist.com/develop/plugins


#3

Thanks, I will follow-up on your suggestion