ap_new_subscriber( integer|false $user_id = false, string $event = '', integer $ref_id )
Description #
Insert new subscriber.
Parameters #
- $user_idinteger | false (Optional) User ID. Default value: false
- $eventstring (Optional) Event type. Default value: ''
- $ref_idinteger (Required) Reference identifier id.
Source #
File: includes/subscribers.php
function ap_new_subscriber( $user_id = false, $event = '', $ref_id = 0 ) { global $wpdb; if ( false === $user_id ) { $user_id = get_current_user_id(); } $exists = ap_get_subscriber( $user_id, $event, $ref_id ); if ( ! $exists ) { $insert = $wpdb->insert( // phpcs:ignore WordPress.DB $wpdb->ap_subscribers, array( 'subs_user_id' => $user_id, 'subs_event' => sanitize_title( $event ), 'subs_ref_id' => $ref_id, ), array( '%d', '%s', '%d' ) ); if ( false !== $insert ) { /** * Hook triggered right after inserting a subscriber. * * @param integer $subs_id Subscription id. * @param integer $user_id User id. * @param string $event Event name. * @param integer $ref_id Reference id. * * @since 4.0.0 */ do_action( 'ap_new_subscriber', $wpdb->insert_id, $user_id, $event, $ref_id ); return $wpdb->insert_id; } } return false; }
Expand full source code Collapse full source code View on GitHub: includes/subscribers.php:30
Add your comment