ap_get_subscribers( array $where = array(), null $event = null, null $ref_id = null )
Description #
Get subscribers. Total subscribers count will be returned if no argument is passed.
Parameters #
- $wherearray (Optional) Where clauses.
- 'subs_event'
(string) Event type. - 'subs_ref_id'
(integer) Reference id. - 'subs_user_id'
(integer) User id.
- 'subs_event'
$event
null (Optional) Deprecated. Default value: null$ref_id
null (Optional) Deprecated. Default value: nullSource #
File: includes/subscribers.php
function ap_get_subscribers( $where = array(), $event = null, $ref_id = null ) { if ( null !== $event || null !== $ref_id ) { _deprecated_argument( __FUNCTION__, '4.1.5', esc_attr__( 'All 2 arguments $event and $ref_id are deprecated.', 'anspress-question-answer' ) ); } global $wpdb; $where = wp_parse_args( $where, array( 'subs_event' => '', 'subs_ref_id' => '', 'subs_user_id' => '', ) ); $where = wp_array_slice_assoc( $where, array( 'subs_event', 'subs_ref_id', 'subs_user_id' ) ); // Return if where clauses are empty. if ( empty( $where ) ) { return; } $query = ''; if ( isset( $where['subs_ref_id'] ) && $where['subs_ref_id'] > 0 ) { $query .= $wpdb->prepare( ' AND s.subs_ref_id = %d', $where['subs_ref_id'] ); } if ( ! empty( $where['subs_event'] ) ) { $query .= $wpdb->prepare( ' AND s.subs_event = %s', $where['subs_event'] ); } if ( ! empty( $where['subs_user_id'] ) ) { $query .= $wpdb->prepare( ' AND s.subs_user_id = %s', $where['subs_user_id'] ); } $results = $wpdb->get_results( "SELECT * FROM {$wpdb->ap_subscribers} s LEFT JOIN {$wpdb->users} u ON u.ID = s.subs_user_id WHERE 1=1 {$query}" ); // phpcs:ignore WordPress.DB return $results; }
Expand full source code Collapse full source code View on GitHub: includes/subscribers.php:153
Add your comment