Forum prefix doesn't work
3 posters
Page 1 of 1
Forum prefix doesn't work
Forum URL: https://academy.forumotion.me/
Version: ModernBB
I shared on my forum an article about sexual harrasmant and what causes such things during war (psychology point of view). Here is the link to that topic: https://academy.forumotion.me/t112-undefined-why-is-sexual-violence-so-common-in-war
But, when I select prefix to be article, and go to post topic, they ask me to confirm by captcha and when I do, it says undefined prefix. Why I get captcha message? Is it because of the article content?
Version: ModernBB
I shared on my forum an article about sexual harrasmant and what causes such things during war (psychology point of view). Here is the link to that topic: https://academy.forumotion.me/t112-undefined-why-is-sexual-violence-so-common-in-war
But, when I select prefix to be article, and go to post topic, they ask me to confirm by captcha and when I do, it says undefined prefix. Why I get captcha message? Is it because of the article content?
Last edited by Academic on February 16th 2023, 8:26 pm; edited 1 time in total
Guest- Guest
Re: Forum prefix doesn't work
This one:
The problem is not in the code. Issue is when I click to post the topic, I get redirected to solve captcha and during that time, things get messed up.
- Code:
var prefixes = ["News", "Article", "Tutorial", "Help"]; //your prefixes
var _pm = false; //true: allowed prefixes in pm
var chk = false;
function toMenu(a) {
var htmlpre = '<select style="margin-right:5px" id="prefix" size="1"><option value="">(None)</option>';
for (i in a)
htmlpre += '<option value="' + a[i] + '">' + a[i] + '</option>';
htmlpre += '</select>';
return htmlpre;
}
function checkpre(ar, input) {
for (i in ar) {
var p = new RegExp("\\" + ar[i], "g");
var title = input.substr(0, input.indexOf(']'));
if (p.test(title)) return ar[i];
}
return "";
}
$(function () {
if (_pm) chk = /\privmsg/.test(location.href);
if (/\/post/.test(location.href) || chk) {
$(toMenu(prefixes)).insertBefore("input[name='subject'][type='text']");
var mw = $("#prefix").width() + 5;
$("input[name='subject']").css("width", $("input[name='subject']").width() - mw);
var t = $("[name='subject']").val();
var cur = checkpre(prefixes, t);
if (cur != "") {
$("[value=" + cur + "]").attr("selected", "selected");
$("input[name='subject']").val(t.replace('[' + cur + ']', '').trim())
}
$("input[name='post']").click(function () {
var sub = $("input[name='subject']").val().trim();
if (sub != "" && $("#prefix").val() != "") $("input[name='subject']").val("[" + $("#prefix").val() + "] " + sub)
})
}
});
$(function () {
$("a[href^='/t'], a[href^='http://" + location.host + "/t']").html(function () {
var a = $(this).text();
if(/^\[([^\[\]]+)\]/.test(a)) return a.replace(/^\[[^\[\]]+\]/, function (a) {
return '<span class="prefix ' + a + '">' + a.slice(1,-1) + "</span>"
})
});
});
The problem is not in the code. Issue is when I click to post the topic, I get redirected to solve captcha and during that time, things get messed up.
Guest- Guest
Re: Forum prefix doesn't work
Hello,
You may be faced to a Captcha when you attempt to post or edit a message which contains a certain word which has been blacklisted / put on a security list because it is sometimes present in spam messages, unsolicited messages or posts made by bots or spammers to pollute forums.
It is a security check therefore we don't have any control over that.
So, let's try to correct your javascript to make it working even if you have to pass the Captcha step.
The issue looks to be with this condition :
But if this input is simply absent on the page, it returns undefined, and undefined != "", so the condition is executed and the prefix is turned in "undefined".
To fix it, replace this line with the following :
Let me know if it works for you,
Regards.
You may be faced to a Captcha when you attempt to post or edit a message which contains a certain word which has been blacklisted / put on a security list because it is sometimes present in spam messages, unsolicited messages or posts made by bots or spammers to pollute forums.
It is a security check therefore we don't have any control over that.
So, let's try to correct your javascript to make it working even if you have to pass the Captcha step.
The issue looks to be with this condition :
- Code:
if (sub != "" && $("#prefix").val() != "") $("input[name='subject']").val("[" + $("#prefix").val() + "] " + sub)
But if this input is simply absent on the page, it returns undefined, and undefined != "", so the condition is executed and the prefix is turned in "undefined".
To fix it, replace this line with the following :
- Code:
if (sub != "" && $("#prefix").val()) $("input[name='subject']").val("[" + $("#prefix").val() + "] " + sub)
Let me know if it works for you,
Regards.
TonnyKamper likes this post
Re: Forum prefix doesn't work
chattigre wrote:Hello,
You may be faced to a Captcha when you attempt to post or edit a message which contains a certain word which has been blacklisted / put on a security list because it is sometimes present in spam messages, unsolicited messages or posts made by bots or spammers to pollute forums.
It is a security check therefore we don't have any control over that.
So, let's try to correct your javascript to make it working even if you have to pass the Captcha step.
The issue looks to be with this condition :If the input#prefix is present on the post page but is empty, the .val() method returns an empty string.
- Code:
if (sub != "" && $("#prefix").val() != "") $("input[name='subject']").val("[" + $("#prefix").val() + "] " + sub)
But if this input is simply absent on the page, it returns undefined, and undefined != "", so the condition is executed and the prefix is turned in "undefined".
To fix it, replace this line with the following :
- Code:
if (sub != "" && $("#prefix").val()) $("input[name='subject']").val("[" + $("#prefix").val() + "] " + sub)
Let me know if it works for you,
Regards.
Okay, now undefined is gone, but it seems I can't put any prefix due to words prohibited by Forumotion team. Too bad. It's a psychological point of view, academic. Let's say it's solved.
Guest- Guest
Re: Forum prefix doesn't work
Hello again,
No, let's try to fix it, normally it will be easy, I just did'nt think about it
Just let me a few hours to do it because now I have to go, but I will come back to you with a fix as soon as possible this evening or tomorrow !
(Think to remove Solved icon if you want me to do so, otherwise your topic may be archived)
Regards
No, let's try to fix it, normally it will be easy, I just did'nt think about it
Just let me a few hours to do it because now I have to go, but I will come back to you with a fix as soon as possible this evening or tomorrow !
(Think to remove Solved icon if you want me to do so, otherwise your topic may be archived)
Regards
Re: Forum prefix doesn't work
Hello again,
Assuming prefix is editable only if "subject" field is an editable text input and not if it is an hidden input, try to replace :
by
So if the subject field is hidden and just present as an hidden fallback / saved field, the JS won't be executed making the prefix consistent.
I hope this will completely solve your issue this time, otherwise please feel free to advise me of any other unexpected behavior.
Regards
Assuming prefix is editable only if "subject" field is an editable text input and not if it is an hidden input, try to replace :
- Code:
if (/\/post/.test(location.href) || chk) {
by
- Code:
if (($('input[name="subject"][type="text"]').length) && (/\/post/.test(location.href) || chk)) {
So if the subject field is hidden and just present as an hidden fallback / saved field, the JS won't be executed making the prefix consistent.
I hope this will completely solve your issue this time, otherwise please feel free to advise me of any other unexpected behavior.
Regards
Re: Forum prefix doesn't work
Is this solved now?
Lost Founder's Password |Forum's Utilities |Report a Forum |General Rules |FAQ |Tricks & Tips
You need one post to send a PM.
You need one post to send a PM.
When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
Similar topics
» URGENT! The forum doesnt work at all!
» FMChat - auto login doesnt work
» Prefix script doesn't work
» New Registration Doesnt work
» chatbox java doesnt work
» FMChat - auto login doesnt work
» Prefix script doesn't work
» New Registration Doesnt work
» chatbox java doesnt work
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum