So I now have added the following to the function.php: correct?
/**
* @param array $reviewValues
* author => the reviewer's name
* email => the reviewer's email
* assigned_to => the post_id of the page the review is assigned to
* content => the review text
* rating => the review rating (1-5)
* title => the review title
* date => the review date
* @param string $reviewCategory The taxonomy ID or slug
* @return void
*
* Example usage:
* createSiteReview([
* 'author' => 'Jane Doe',
* 'email' => '[email protected]',
* 'content' => 'This is my review.',
* 'rating' => '5',
* 'title' => 'Amazing Service!',
* 'date' => gmdate( ‘Y-m-d H:i:s’, strtotime( ’22-09-2008′ )),
* ]);
**/
function createSiteReview( array $reviewValues, $reviewCategory = '' ) {
if( !function_exists( 'glsr_resolve' ))return;
$database = glsr_resolve( 'Database' );
$user = wp_get_current_user();
$review = wp_parse_args( $reviewValues, [
'author' => $user->exists() ? $user->display_name : '',
'email' => $user->exists() ? $user->user_email : '',
'assigned_to' => '',
'content' => '',
'ip_address' => glsr_resolve( 'Helper' )->getIpAddress(),
'rating' => '0',
'review_type' => 'local',
'title' => '',
'date' => '',
]);
$review['avatar'] = get_avatar_url( $review['email'] );
$post_id = $database->createReview( $review, (object)['blacklisted' => false] );
$database->setReviewMeta( $post_id, $reviewCategory );
}