• Resolved arbremojo

    (@arbremojo)


    Hi,

    I would like to prepropulate fields in user account. By default, only email address is prepopulated. How can I do it for all the custom fields I added?

    Best regards,

    Clara.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter arbremojo

    (@arbremojo)

    Solved!

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @arbremojo

    Thanks for letting us know.

    Regards,

    Can you describe what you did to enable this?

    I need that answer also please

    Thread Starter arbremojo

    (@arbremojo)

    I used this code written in functions.php file to add extra UM fields (we can find in UM registration form):

    /* add custom user fields */
    add_action('um_after_account_general', 'showUMExtraFields', 100);
    
    function showUMExtraFields()
    {
        $id = um_user('ID');
        $output = '';
        $names = array(
            'phone_number',
            'company_name',
            'job',
            'street',
            'zipcode',
            'city'
            );
    
        $fields = array();
        foreach( $names as $name )
        {
            $fields[ $name ] = UM()->builtin()->get_specific_field( $name );
        }
    
        $fields = apply_filters('um_account_secure_fields', $fields, $id);
    
        foreach( $fields as $key => $data )
            $output .= UM()->fields()->edit_field( $key, $data );
    
        echo $output;
    }

    The $names variable is an array of meta key. This meta key is set in field settings.

    Thanks to this function, UM will populate automatically the fields in account.

    Thanks so much that worked.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Prepropulate account fields’ is closed to new replies.