• Resolved littler79

    (@littler79)


    I’m trying to give the user the option to remain anonymous when they post a review. (users need to be logged in when posting a review).
    I’ve tried using add_filter(‘site-reviews/create/review-values’ and checking if the name is blank, then put in ‘Anonymous’ instead, but it seems to default in the user’s name before I get the chance to check for blank.
    I’ve also tried adding a checkbox so they can tick ‘I want to be anonymous’ but then if I use the filter as above, it doesn’t pick up my custom form field (even though it is shown on the page).
    Any ideas?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Gemini Labs

    (@geminilabs)

    Why not just change the name format of displayed reviews?

    Plugin Author Gemini Labs

    (@geminilabs)

    If you really only want to do this if they specifically want to remain anonymous (i.e. by checking a checkbox), then assuming the checkbox field is a custom field with a field name of “anonymous”, you can do this:

    add_action('site-reviews/review/build/before', function ($review) {
        if ($review->custom->anonymous) {
            $review->set('author', 'Anonymous');
        }
    });
    Thread Starter littler79

    (@littler79)

    Thank you so much, this is the code I needed, I’ve got it working now.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Anonymous Author’ is closed to new replies.