Hi All
Is anyway we enable quote button for Guest to quote ?
Thanks
Is anyway we enable quote button for Guest to quote ?
Thanks
Last edited by TamDonCo on January 11th 2019, 6:54 pm; edited 1 time in total
SLGray wrote:If guests are allowed to post on your forum, they should be able to see all the buttons in the topic. Â Could you post a link to a topic that guests can reply to.
document.addEventListener("DOMContentLoaded", function(){
if(_userdata.user_id===-1){
var css=".button_guest_quote{float:right;background:#00689A;color:white !important;padding:5px;font-size:15px;}";
var style=document.createElement("style");
style.innerHTML=css;
document.querySelector("head").appendChild(style);
var posts=document.querySelectorAll(".post"), insafter=document.querySelectorAll("h2.topic-title"), len=posts.length, id, button;
if(len!==0){
for(var i=0;i<len;i++){
id=parseInt(posts[i].getAttribute("id").match(/\d+/)[0]);
if(id!==0){
button=document.createElement("a");
button.classList.add("button_guest_quote");
button.innerHTML="Quote";
button.setAttribute("href", "/post?p="+id+"&mode=quote");
insafter[i].parentNode.insertBefore(button, insafter[i].nextSibling);
}
}
}
}
})
Menim wrote:Actually that code is correct both with 2 "=" and with 3 "=". With 2 "=" it compares the value of _userdata.user_id with -1(-1 meaning that the user is a guest). WIth 3 "=" it compares both the values and the types. In this case, there's no difference between them, but I usually use === because its generally safer than ==. For example, "2"==2 is true, but "2"===2 is false, because "2" is a string and 2 is an integer.
Nonetheless, glad the code works.
Problem solved & topic archived.
|