You appear to be a bot. Output may be restricted
Description
Creates a customer
Usage
$mixed = EDD_Customer::create( $data );
Parameters
- $data
- ( array ) optional – Array of attributes for a customer
Returns
mixed False if not a valid creation, Customer ID if user is found or valid creation
Source
File name: easy-digital-downloads/includes/class-edd-customer.php
Lines:
1 to 53 of 53
public function create( $data = array() ) { if ( $this->id != 0 || empty( $data ) ) { return false; } $defaults = array( 'payment_ids' => '' ); $args = wp_parse_args( $data, $defaults ); $args = $this->sanitize_columns( $args ); if ( empty( $args['email'] ) || ! is_email( $args['email'] ) ) { return false; } if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) { $args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) ); } /** * Fires before a customer is created * * @param array $args Contains customer information such as payment ID, name, and email. */ do_action( 'edd_customer_pre_create', $args ); $created = false; // The DB class 'add' implies an update if the customer being asked to be created already exists if ( $this->db->add( $data ) ) { // We've successfully added/updated the customer, reset the class vars with the new data $customer = $this->db->get_customer_by( 'email', $args['email'] ); // Setup the customer data with the values from DB $this->setup_customer( $customer ); $created = $this->id; } /** * Fires after a customer is created * * @param int $created If created successfully, the customer ID. Defaults to false. * @param array $args Contains customer information such as payment ID, name, and email. */ do_action( 'edd_customer_post_create', $created, $args ); return $created; }