ap_update_user_unpublished_count( integer|null $user_id = null )
Description #
Update unpublished posts counts of a user.
Parameters #
- $user_idinteger | null (Optional) User ID to update. Default value: null
Source #
File: includes/qameta.php
function ap_update_user_unpublished_count( $user_id = null ) { global $wpdb; if ( null === $user_id ) { $user_id = get_current_user_id(); } $counts = $wpdb->get_results( $wpdb->prepare( "SELECT COUNT(*) as count, post_type FROM $wpdb->posts WHERE post_status IN ('draft', 'moderate', 'pending', 'trash') AND post_author = %d AND post_type IN ('question', 'answer') GROUP BY post_type", $user_id ) ); // phpcs:ignore WordPress.DB if ( ! empty( $counts ) ) { $counts = wp_list_pluck( $counts, 'count', 'post_type' ); } $q_count = ! empty( $counts['question'] ) ? (int) $counts['question'] : 0; $a_count = ! empty( $counts['answer'] ) ? (int) $counts['answer'] : 0; // Update questions count. update_user_meta( $user_id, '__ap_unpublished_questions', $q_count ); // Update answers count. update_user_meta( $user_id, '__ap_unpublished_answers', $a_count ); }
Expand full source code Collapse full source code View on GitHub: includes/qameta.php:644
Klreley
[email protected]
:
Abu Dhabi home cleaning companies https://alprofessoruae-com/