1

I need to save this to database, but could not find a way to make it work. Now this paypal_email is only saved to current user. Apparently it is saved somehow to the database under user table, but it can not be read there? Or use views to read it.

function commerce_funds_manage_withdrawal_method_paypal($form, &$form_state) {

  $enabled_methods = variable_get('commerce_funds_withdrawal_methods', array());

  if (!$enabled_methods['paypal'])
    return FALSE;

  global $user;

  $form['paypal_email'] = array(
      '#type' => 'textfield',
      '#title' => t('Paypal Email'),
      '#description' => t('Withdrawals using Paypal will be sent to this email'),
      '#default_value' => $user->data && array_key_exists('paypal', $user->data) ? $user->data['paypal']['paypal_email'] : '',
      '#size' => 40,
      '#maxlength' => 64,
      '#required' => TRUE,
  );

  $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Save'),
  );

  return $form;
}

function commerce_funds_manage_withdrawal_method_paypal_submit($form, &$form_state) {

  global $user;

  user_save($user, array('data' => array('paypal' => $form_state['values'])));
}

1 Answer 1

3

I don't think the $user->data value can be read by views. You are probably better off creating a field to store the email value.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.