inherit
173855
0
Apr 23, 2024 9:59:44 GMT -8
Texas
I check in every once in a while...
869
November 2011
petermaggio
|
Post by Texas on Nov 2, 2012 18:58:58 GMT -8
Okay so the code is supposed to prevent certain users from editing there posts. (through use of greasemonky) I know that the main part of the code works but I can't figure out how to get the if statement correct or get it so that you block multiple users.
This is what I have so far.
<script> if (proboards.data('user').id == 173855)
lnk=document.getElementsByTagName('a'); for (i=0; i<lnk.length; i++) { if (lnk.href.match(/edit/i)) { lnk.style.display="none"; } } } </script>
|
|
inherit
139970
0
Dec 31, 2013 3:41:16 GMT -8
Luke
Rawhhh =D
1,780
April 2009
harry12345
|
Post by Luke on Nov 2, 2012 22:59:18 GMT -8
<script type ="text/javascript"> if (proboards.data('user').id == "173855"){
lnk=document.getElementsByTagName('a'); for (i=0; i<lnk.length; i++) { if (lnk.href.match(/edit/i)) { lnk.style.display="none"; } } } </script>
In theory that should work.
|
|
inherit
14706
0
Jan 28, 2021 15:41:20 GMT -8
Xikeon
170
October 2003
mikeo
|
Post by Xikeon on Nov 3, 2012 2:38:24 GMT -8
Tested and works, in footer:
<script type ="text/javascript"> if( proboards.data('user').id === "173855" ){ $('.edit-button').hide(); } </script>
Or of you want it in plugin JS / header you should do it on document load (jQuery).
|
|
inherit
173855
0
Apr 23, 2024 9:59:44 GMT -8
Texas
I check in every once in a while...
869
November 2011
petermaggio
|
Post by Texas on Nov 3, 2012 3:34:13 GMT -8
Wait so if you pluged that into your v5 forum and put your user ID in for mine it actually worked? Cause I couldn't get the same results using greasemonky (must be something weird that greasemonkey does)
Do you know how I would be able to use a variable to get multiple users to be blocked at once?
|
|
inherit
14706
0
Jan 28, 2021 15:41:20 GMT -8
Xikeon
170
October 2003
mikeo
|
Post by Xikeon on Nov 3, 2012 4:22:54 GMT -8
Yes. <script type ="text/javascript"> var users = ["1", "2"] if( $.inArray( proboards.data('user').id, users ) > -1 ){ $('.edit-button').hide(); } </script>
|
|
inherit
173855
0
Apr 23, 2024 9:59:44 GMT -8
Texas
I check in every once in a while...
869
November 2011
petermaggio
|
Post by Texas on Nov 3, 2012 5:16:55 GMT -8
Why is it "in users" and not "== users" ?
|
|
inherit
14706
0
Jan 28, 2021 15:41:20 GMT -8
Xikeon
170
October 2003
mikeo
|
Post by Xikeon on Nov 3, 2012 16:23:52 GMT -8
Because users is an array with the ID's of users you want to hide the edit button from. Then with the line:
if( proboards.data('user').id in users ) { It's checking if the current logged in user's ID is found in the array. If so, then hide the link.
Edit: ignore this, fixed code is above.
|
|
inherit
97216
0
Nov 23, 2024 12:51:52 GMT -8
Bennett 🚀
Formerly iPokemon.
3,622
January 2007
catattack
iPokemon's Mini-Profile
|
Post by Bennett 🚀 on Nov 4, 2012 16:19:22 GMT -8
Because users is an array with the ID's of users you want to hide the edit button from. Then with the line: if( proboards.data('user').id in users ) { It's checking if the current logged in user's ID is found in the array. If so, then hide the link. $.inArray should be used, not "in users".
|
|
inherit
14706
0
Jan 28, 2021 15:41:20 GMT -8
Xikeon
170
October 2003
mikeo
|
Post by Xikeon on Nov 4, 2012 16:29:26 GMT -8
Ah man, I was tired when I wrote that. Wasn't thinking straight and for some reason got it mixed up with an object. Fixed in original post.
|
|
inherit
173855
0
Apr 23, 2024 9:59:44 GMT -8
Texas
I check in every once in a while...
869
November 2011
petermaggio
|
Post by Texas on Nov 4, 2012 17:37:28 GMT -8
Okay so I'm trying to make it so the array can be edited using the user interface but I can't figure out where to put the this part: $[plugin.settings.users]
Right now I have it like this:
<script type ="text/javascript"> var users = $[plugin.settings.users] if( $.inArray( proboards.data('user').id, users ) ){ $('.edit-button').hide(); } </script>
But I know that's wrong. I somehow have to put it in the line in red but I'm not sure where.
|
|
inherit
14706
0
Jan 28, 2021 15:41:20 GMT -8
Xikeon
170
October 2003
mikeo
|
Post by Xikeon on Nov 5, 2012 3:58:24 GMT -8
Okay, so what you want to do is. Go to the user interface and make sure you choose for Forum Search. Then set the variable ID to users and make sure Search type is set to Members. Save that, go to components and add the following to the JS box.I'm currently having issues with the Forum Search component, so I'm filing a bug for that. Once that's fixed I'll get back to you. (Bug thread: here)
|
|
inherit
173855
0
Apr 23, 2024 9:59:44 GMT -8
Texas
I check in every once in a while...
869
November 2011
petermaggio
|
Post by Texas on Nov 6, 2012 11:25:22 GMT -8
Okay so the thing is back up.....so what were you going to tell me?
|
|
inherit
14706
0
Jan 28, 2021 15:41:20 GMT -8
Xikeon
170
October 2003
mikeo
|
Post by Xikeon on Nov 7, 2012 1:35:26 GMT -8
Yea, I noticed it was back up. Sorry for the late reply, haven't been home in meantime. Here's a working plugin, editable so you can do with it as you wish. Figured that would make more sense with the export feature now :-). Attachments:No edit.pbp (428 B)
|
|
inherit
173855
0
Apr 23, 2024 9:59:44 GMT -8
Texas
I check in every once in a while...
869
November 2011
petermaggio
|
Post by Texas on Nov 7, 2012 7:41:39 GMT -8
Uh......how do you remove people from the code? I added my self but cant figure out how to remove it.....so now I can't edit my posts
|
|
inherit
14706
0
Jan 28, 2021 15:41:20 GMT -8
Xikeon
170
October 2003
mikeo
|
Post by Xikeon on Nov 7, 2012 9:26:44 GMT -8
There's a cross behind your name
|
|