Hello,
thanks for your answer.
Unfortunately the behavior is not what I was expecting:
it seems that, when you write the title, there is not any limit and you can write as much as you want.
BUT, if you try to submit the review, the review is not submitted and no advice or message about unsuccessful submitting is shown.
Is there a way to better handle this situation of long title?
Something that shows the limit when you write it or that tells you that the review is not submitted since the title is too long?
As I showed you in first message, it seems a big bug since all the reviews become unformatted if the title of one is too long (and without spacing).
Thanks a lot,
Daniele
1. If the error message is not displaying, then your website is probably not loading the Site Reviews javascript file. If you are using a caching or optimisation plugin, you should check the settings. This is what it should look like: https://imgur.com/WIcfRAk
2. This is not exactly a bug. If you are concerned about someone submitting a really long title with no spaces (this would likely only happen if someone is trying to spam you), then you can enable the “Require Approval” setting, enable one or more of the provided anti-spam options, and/or use the solution provided above.
3. You can also use the following CSS solution (although it will not work with Internet Explorer):
.glsr-review-title {
overflow-wrap: anywhere;
}
Hello,
option 1 would be fine for me, and I guess the javascript file is loaded because in the other fields I receive the warning, as you can see here:
https://imgur.com/a/mLXcBHb
But for the title, I do not receive any red warning even if I write more than 80 character. In this case, the review seems submitted but actually it is not.
Here you can see that I do not receive the red warning (I wrote more than 80 words):
https://imgur.com/a/yIdLBdq
Maybe I should add something to the code?
Thanks in advance as always,
Daniele
1. Please show a screenshot of how you are using the code snippet.
2. Are you using any other snippets?
3. Have you done any other customisations?
Hello,
here a screenshot of my snippet, below there is another one to limit also the length of the review content:
https://imgur.com/a/6mT2lTh
Limit the length of review actually works, means that if I try to write more than 500 characters, I just can’t (I do not receive any red warning when try to submit, simply because I cannot write more than 500)
I would prefer some red warning when try to submit like in your example:
https://imgur.com/WIcfRAk
but could be ok also if writing more than 80 characters would not be allowed (like for the review content)
I don’t think I made some other particular customization.
Maybe I should make the code for title similar to the one of the review? Like using the filter “review-form”
Thanks in advance
I’m not sure why the server-side validation is not working for you, although it sounds like a possible javascript or CSS conflict with your theme; without additional information about your website, I won’t be able to help you.
However, if the client-side HTML5 validation is enough for you, then you can do this:
/**
* Client-side validation
*/
add_filter('site-reviews/config/forms/review-form', function ($config) {
if (array_key_exists('title', $config)) {
$config['title']['maxlength'] = 80;
}
if (array_key_exists('content', $config)) {
$config['content']['maxlength'] = 500;
}
return $config;
});
/**
* Server-side validation
*/
add_filter('site-reviews/validation/rules', function ($rules) {
$rules['title'] = 'required|max:80';
$rules['content'] = 'required|max:500';
return $rules;
});
Hello,
thanks for your help.
I tried this implementation and seems working:
https://imgur.com/a/suNp5If
I think it is the same of the one you proposed above, just less clean.. π
Can you confirm?
Thanks for your help, after your confirmation we can close the case π
Daniele