WC_Customer_Download_Data_Store::insert_new_download_permission()
Create download permission for a user, from an array of data. Assumes that all the keys in the passed data are valid.
Method of the class: WC_Customer_Download_Data_Store{}
Hooks from the method
Return
Int
. The database id of the created permission, or false if the permission creation failed.
Usage
// private - for code of main (parent) class only $result = $this->insert_new_download_permission( $data );
- $data(array) (required)
- Data to create the permission for.
WC_Customer_Download_Data_Store::insert_new_download_permission() WC Customer Download Data Store::insert new download permission code WC 9.4.2
private function insert_new_download_permission( $data ) { global $wpdb; // Always set a access granted date. if ( ! isset( $data['access_granted'] ) ) { $data['access_granted'] = time(); } $data['access_granted'] = $this->adjust_date_for_db( $data['access_granted'] ); if ( isset( $data['access_expires'] ) ) { $data['access_expires'] = $this->adjust_date_for_db( $data['access_expires'] ); } $format = array( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%d', '%s', ); $result = $wpdb->insert( $wpdb->prefix . 'woocommerce_downloadable_product_permissions', apply_filters( 'woocommerce_downloadable_file_permission_data', $data ), apply_filters( 'woocommerce_downloadable_file_permission_format', $format, $data ) ); return $result ? $wpdb->insert_id : false; }