I want to create a custom registration for wordpress and I need to create a new custom field for each profile. For example a phone field.
Here's my code
function registration()
{
$userdata = array(
'user_login' => esc_attr($this->username),
'phone' => esc_attr($this->username),
'pre_user_email' => esc_attr($this->email),
'user_pass' => esc_attr($this->password),
'user_url' => esc_attr($this->website),
'first_name' => esc_attr($this->first_name),
'last_name' => esc_attr($this->last_name),
'nickname' => esc_attr($this->nickname),
'description' => esc_attr($this->bio),
);
The phone line is my custom field for profile.
It doesn't work, I've tried creating a custom field in the admin user panel, and it works! But I can't insert data to that field phone
function registration()
{
$userdata = array(
'user_login' => esc_attr($this->username),
'phone' => esc_attr($this->phone),
'pre_user_email' => esc_attr($this->email),
'user_pass' => esc_attr($this->password),
'user_url' => esc_attr($this->website),
'first_name' => esc_attr($this->first_name),
'last_name' => esc_attr($this->last_name),
'nickname' => esc_attr($this->nickname),
'description' => esc_attr($this->bio),
);
}
You should add 'phone' string on MySQL db
Related
I try to do some thing with wordpress social login plugin. I need to put steamid to wp_users table. I have to create colum called steamid in wp_users table.
Trying to do it with:
$userdata = array(
'user_login' => $user_login,
'user_email' => $user_email,
'display_name' => $user_login,
'first_name' => $hybridauth_user_profile->firstName,
'last_name' => $hybridauth_user_profile->lastName,
'user_url' => $hybridauth_user_profile->profileURL,
'description' => $hybridauth_user_profile->description,
'steamid' => $user_login,
'user_pass' => wp_generate_password()
);
But nothing, the table column steamid is still empty. What's wrong?
I clone braintree project from https://github.com/braintree/braintree_php_example. Than I created account https://www.braintreepayments.com/sandbox. I must to return client_token. I debug this code
$result = Braintree\Transaction::sale([
'amount' => $amount,
'paymentMethodNonce' => $nonce,
'options' => [
'submitForSettlement' => true
]
]);
var_dump($result->transaction);
But token = null. Maybe my steps are incorrect?
////////////////////////////////
I did it!
I create user
$result = Braintree_Customer::create([
'firstName' => 'Mike',
'lastName' => 'Jones',
'company' => 'Jones Co.',
'email' => 'mike.jones#example.com',
'phone' => '281.330.8004',
'fax' => '419.555.1235',
'website' => 'http://example.com']);
Than I get customer_id
$result->customer->id;
Than I get token
$clientToken = Braintree_ClientToken::generate([
"customerId" => $result->customer->id
]);
Maybe problem with custom register in https://www.braintreepayments.com/sandbox.
Maybe I didn't put all information
o/
Working on a minor project, and I'm creating a WC order from the admin area (programmatically), and i want to add a line item(Non product/fee to the order after it been created, but how exactly do i do that?
I create a order by doing:
$address = array(
'first_name' => $sBillingFirstName,
'last_name' => $sBillingLastName,
'company' => $sBillingCompanyName,
'email' => $sBillingEmail,
'phone' => $sBillingPhone,
'address_1' => $sBillingAddress1,
'address_2' => $sBillingAddress2,
'city' => $sBillingCity,
'state' => '',
'postcode' => $sBillingZipcode,
'country' => $sBillingCountry,
);
$oOrder = wc_create_order();
$oOrder->set_address( $address, 'billing' );
$oOrder->set_address( $address, 'shipping' );
and normally i would just do add_fee, as seen below to add a "non product" lineitem/fee, but since i dont have a cart object - what am i supposed to do?
wc->cart->add_fee("deposit", 200);
but i don't have a cart object, so how do i go about creating a the deposit in my new order?
Trying to insert random emails like test''#test.com, etc.. and they are inserted into the database. Shouldn't this be automatically prevented by Active Record?
My query:
$data = array(
'name' => ''.$name.'' ,
'email' => ''.$email.'' ,
'country' => ''.$country.'' ,
'phone' => ''.$phone.'' ,
'compid' => ''.$compID.''
);
$this->db->insert('people', $data);
Where all variables are taken from user POST input, such as
$this->input->post('address')
for address.
shouldn't this be:
$data = array(
'name' => $name,
'email' => $email,
'country' => $country,
'phone' => $phone,
'compid' => $compID
);
$this->db->insert('people', $data);
I want to develop a module that add fields to user profile in drupal 7, like phone number and CV ...
and I don't know how to do that (using Database or using fields API)
pls help me.
Any clear tutorials will be appreciated.
Try to follow the following code
$myField_name = "NEW_FIELD_NAME";
if(!field_info_field($myField_name)) // check if the field already exists.
{
$field = array(
'field_name' => $myField_name,
'type' => 'text',
);
field_create_field($field);
$field_instance = array(
'field_name' => $myField_name,
'entity_type' => 'user', // change this to 'node' to add attach the field to a node
'bundle' => 'user', // if chosen 'node', type here the machine name of the content type. e.g. 'page'
'label' => t('Field Label'),
'description' => t(''),
'widget' => array(
'type' => 'text_textfield',
'weight' => 10,
),
'formatter' => array(
'label' => t('field formatter label'),
'format' => 'text_default'
),
'settings' => array(
)
);
field_create_instance($field_instance);
Hope this works... Muhammad.