0
votes

This has been driving me nuts for 2 days and I can't find an answer anywhere on Google so would really appreciate a little help..

I have a custom registration form on my website, which sends the data to a fairly standard PHPBB3 user_add process as follows:

$user_row = array(
                'username'              => request_var('createUsername',''),
                'user_password'         => phpbb_hash(request_var('createPassword','')),
                'user_email'            => request_var('createEmail',''),
                'group_id'              => '2',
                'user_timezone'         => '1.00',
//              'user_dst'              => '0',
                'user_lang'             => 'en',
                'user_type'             => $user_type,
                'user_actkey'           => $user_actkey,
                'user_ip'               => $user->ip,
                'user_regdate'          => time(),
                'user_inactive_reason'  => $user_inactive_reason,
                'user_inactive_time'    => $user_inactive_time,
            );

            // Register user...
            $user_id = user_add($user_row, $cp_data);

            // If creating the user failed, display an error
            if ($user_id === false)
            {
                trigger_error('NO_USER', E_USER_ERROR);
            }

That works fine and I'm happy with it, however, I have created a custom profile field in the Admin Control Panel called 'ea_real_name' which I want to hold the user's real name. This corresponds to a field on the registration form called 'createRealName' (sent through as $_POST['createRealName'])

I know that user_add takes an optional field called 'cp_data', but I can't for the life of me work out how to format this data... Should it be an array (something like 'ea_real_name' => request_var('createRealName','') or something else?

PHPBB's wiki for the field is empty (https://wiki.phpbb.com/Custom_profile::submit_cp_field) so not much help...

Thanks! :-)

1

1 Answers

0
votes

I was right in my assumption! It's an array with the field name prefixed by pf_.

Finally found an answer here: https://www.phpbb.com/community/viewtopic.php?f=71&t=1638905

$cp_data = array(
                    'pf_ea_real_name'  => request_var('createRealName','')
                    );

Is the correct way to do it...