ap_vote_insert( integer $post_id, integer $user_id, string $type = 'vote', integer|false $rec_user_id, string $value = '', string|false $date = false )
Description #
Insert vote in ap_votes table.
Parameters #
- $post_idinteger (Required) Post ID.
- $user_idinteger (Required) ID of user casting voting.
- $typestring (Optional) Type of vote. Default value: 'vote'
- $rec_user_idinteger | false (Required) Id of user receiving vote.
- $valuestring (Optional) Value of vote. Default value: ''
- $datestring | false (Optional) Date of vote, default is current time. Default value: false
Source #
File: includes/votes.php
function ap_vote_insert( $post_id, $user_id, $type = 'vote', $rec_user_id = 0, $value = '', $date = false ) { if ( false === $date ) { $date = current_time( 'mysql' ); } if ( false === $user_id ) { $user_id = get_current_user_id(); } global $wpdb; $args = array( 'vote_post_id' => $post_id, 'vote_user_id' => $user_id, 'vote_rec_user' => $rec_user_id, 'vote_type' => $type, 'vote_value' => $value, 'vote_date' => $date, ); $inserted = $wpdb->insert( $wpdb->ap_votes, $args, array( '%d', '%d', '%d', '%s', '%s', '%s' ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery if ( $inserted ) { /** * Action triggered after inserting a vote. * * @param array $args Vote arguments. * @since 4.0.0 */ do_action( 'ap_insert_vote', $args ); return true; } return false; }
Expand full source code Collapse full source code View on GitHub: includes/votes.php:162
Add your comment