Viewing 6 replies - 16 through 21 (of 21 total)
  • Plugin Author Gemini Labs

    (@geminilabs)

    No, you shouldn’t add the date to the function because the date is probably different for each review. You instead pass the date into the function when you use it, as I showed in the example above.

    The difference in the updated function is this line:

    $post_id = $database->createReview( $review, (object)['blacklisted' => false] );

    • This reply was modified 6 years, 8 months ago by Gemini Labs.
    Thread Starter Christopher Hilling

    (@chilling)

    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 );
    }
    
    Thread Starter Christopher Hilling

    (@chilling)

    Thanks, @geminilabs that has worked perfectly.

    I would suggest that it is probably worth adding to your excellent sample code page :
    1. the additional date variable into the function
    2. the following line in the example: 'date' => gmdate( ‘Y-m-d H:i:s’, strtotime( ’22-09-2008′ )),
    3. the category parameter to the example too; and
    4. a note that the Approve setting has to be off to enable the import of the review dates

    I know it is probably obvious to you but I would not have got there without your splendid help.

    Again – thank you.

    Plugin Author Gemini Labs

    (@geminilabs)

    No problem, I’m happy to help.

    If you have a moment, please consider leaving a positive review for the plugin.
    Thanks.

    • This reply was modified 6 years, 8 months ago by Gemini Labs.

    Hi Paul,

    Thank you for sharing this excellent review plugin. I have an xml file with over 1000 reviews from my old website which was on a different platform. I would very much like to import these so my customer base doesn’t think I just binned them all ! Unlike C.hilling i’m not much of a coder. Can you offer this as a service? or provide instructions as to where to paste the aforementioned code. I can just about cut and paste under directions! and can certainly clean up the mxl file of unrequired fields, etc. Thank you in advance for your time and expertise. Harry

    Plugin Author Gemini Labs

    (@geminilabs)

    @harrygr0wler Would you be able to send me the xml file to inspect? Please send it if possible to the email shown on the “Site Reviews > Get Help” page.

Viewing 6 replies - 16 through 21 (of 21 total)
  • The topic ‘Import existing reviews’ is closed to new replies.