• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
Easy Digital Downloads a2z

Easy Digital Downloads a2z

Easy Digital Downloads a2z

  • Home
  • Plugins
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / EDD_Customer::create() – Creates a customer

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;

  }
 

 View on GitHub View on Trac

Published: 26th November 2019 | Last updated: 12th September 2021

Primary Sidebar

Information

Function name: EDD_Customer::create
Class ref: EDD_Customer
Plugin ref: Easy Digital Downloads
Version: 2.11.6
Sourcefile: includes/class-edd-customer.php
File ref: includes/class-edd-customer.php
Deprecated?: No
API Letters: C,E

Footer

Easy Digital Downloads a2z
Easy Digital Downloads a2z
Easy Digital Downloads a2z
WordPress 5.9.3
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  edd.wp-a2z.org
© Copyright Easy Digital Downloads a2z 2014-2022. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites