You appear to be a bot. Output may be restricted
Description
Set an email address as the customer's primary email
This will move the customer's previous primary email to an additional email
Usage
$bool = EDD_Customer::set_primary_email( $new_primary_email );
Parameters
- $new_primary_email
- ( string ) optional – The email address to remove from the customer
Returns
bool If the email was set as primary successfully
Source
File name: easy-digital-downloads/includes/class-edd-customer.php
Lines:
1 to 52 of 52
public function set_primary_email( $new_primary_email = '' ) { if( ! is_email( $new_primary_email ) ) { return false; } do_action( 'edd_customer_pre_set_primary_email', $new_primary_email, $this->id, $this ); $existing = new EDD_Customer( $new_primary_email ); if( $existing->id > 0 && (int) $existing->id !== (int) $this->id ) { // This email belongs to another customer return false; } $old_email = $this->email; // Update customer record with new email $update = $this->update( array( 'email' => $new_primary_email ) ); // Remove new primary from list of additional emails $remove = $this->remove_email( $new_primary_email ); // Add old email to additional emails list $add = $this->add_email( $old_email ); $ret = $update && $remove && $add; if( $ret ) { $this->email = $new_primary_email; $payment_ids = $this->get_payment_ids(); if( $payment_ids ) { foreach( $payment_ids as $payment_id ) { // Update payment emails to primary email edd_update_payment_meta( $payment_id, 'email', $new_primary_email ); } } } do_action( 'edd_customer_post_set_primary_email', $new_primary_email, $this->id, $this ); return $ret; }