Exclude User ID From Javascript

Go down

Solved Exclude User ID From Javascript

Post by timberella on May 20th 2018, 12:47 am

I have installed this Javascript module to hide profile signatures in certain topics/forums/categories.

Code:
$(function(){

/* --- CONFIGURATION --- */
// Topic IDs where the signatures are hidden
var topic_ids = [1, 2, 3];
// Forum IDs where the signatures are hidden
var forum_ids = [4, 5];
// Category IDs where the signatures are hidden
var cat_ids = [7];
/* --- CONFIGURATION --- */

var topic_match = window.location.pathname.match(/\/t(\d+)/); if (!topic_match) return;
  var current_topic = topic_match[1];
  var navbar = document.querySelector('.pathname-box');
  if (!current_topic || !navbar) return;
  var forum_selector = navbar.querySelectorAll('.nav');
  var current_forum = forum_selector[forum_selector.length - 1]; if (!current_forum) return;
  var forum_match = current_forum.href.match(/\/f(\d+)/); if (!forum_match) return;
  current_forum = forum_match[1]; if (!current_forum) return;
  if (topic_ids.includes(parseInt(current_topic)) || forum_ids.includes(parseInt(current_forum))) {
    $('.signature_div').filter(function(){ this.style.display = "none" });
  }
  var cat_selector = navbar.querySelectorAll('.nav');
  var current_cat = cat_selector[cat_selector.length - 2]; if (!current_cat) return;
  var cat_match = current_cat.href.match(/\/c(\d+)/); if (!cat_match) return;
  current_cat = cat_match[1]; if (!current_cat) return;
  if (topic_ids.includes(parseInt(current_topic)) || cat_ids.includes(parseInt(current_cat))) {
    $('.signature_div').filter(function(){ this.style.display = "none" });
  }
});

I have a member who would like to view the profile signatures in one of these categories, so I want to ask if there is some code that can be added to my code above for excluding a member based on their user ID.  It would make her so happy if this can be done.  Thanks in advance for whatever you can do!

Our forum is phpbb3.
avatar
timberella
Forumember

Female Posts : 63
Reputation : 2
Language : English

http://pinkpalace.forumotion.com/

Back to top Go down

Solved Re: Exclude User ID From Javascript

Post by SLGray on May 20th 2018, 12:58 am

I believe it would be easier if you used a code that hide all signatures,but there would be a button to click to view the signatures.


When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.

avatar
SLGray
Administrator
Administrator

Male Posts : 43893
Reputation : 3124
Language : English
Location : United States

http://fmthemesdesignteam.forumotion.com/

Back to top Go down

Solved Re: Exclude User ID From Javascript

Post by timberella on May 20th 2018, 1:11 am

Thank you for the reply, @SLGray.

If your suggestion is possible, then I would be happy to receive that code and give that suggestion a try.
avatar
timberella
Forumember

Female Posts : 63
Reputation : 2
Language : English

http://pinkpalace.forumotion.com/

Back to top Go down

Solved Re: Exclude User ID From Javascript

Post by SLGray on May 20th 2018, 1:27 am

http://fmdesign.forumotion.com/t196-clip-and-toggle-signatures

You can change the height part of the code to zero that will hide all signatures. Then you just have to click the button to see them.


When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.

avatar
SLGray
Administrator
Administrator

Male Posts : 43893
Reputation : 3124
Language : English
Location : United States

http://fmthemesdesignteam.forumotion.com/

Back to top Go down

Solved Re: Exclude User ID From Javascript

Post by timberella on May 20th 2018, 2:35 am

This code looks like you would have to click a button on a reply-by-reply basis to reveal the signature.
Is that correct?

I would need a button that would reveal all the signatures on a page, not just one at a time.
avatar
timberella
Forumember

Female Posts : 63
Reputation : 2
Language : English

http://pinkpalace.forumotion.com/

Back to top Go down

Solved Re: Exclude User ID From Javascript

Post by Draxion on May 20th 2018, 2:47 am

Based on your first question regarding that script, are you saying you want to enable a member (the one with the ID) to be excluded from the script?


NEVER provide your founder's account or email
Please provide forum's URL when dealing with design and appearance issues
Don't forget to mark the topic as when the issue is resolved. This helps the staff greatly.
PM Support is prohibited!
TOS | General Rules | FAQ | Tricks & Tips | Latest Updates | Introduce Yourself

avatar
Draxion
Support Moderator
Support Moderator

Male Posts : 2188
Reputation : 278
Language : English
Location : USA

http://www.draxionsgameden.com/

Back to top Go down

Solved Re: Exclude User ID From Javascript

Post by Wecoc on May 20th 2018, 3:30 am

Here's it.

Code:
$(function(){
if ([4].includes(_userdata.user_id)) return;
 
/* --- CONFIGURATION --- */
// Topic IDs where the signatures are hidden
var topic_ids = [1, 2, 3];
// Forum IDs where the signatures are hidden
var forum_ids = [4, 5];
// Category IDs where the signatures are hidden
var cat_ids = [7];
/* --- CONFIGURATION --- */
 
var topic_match = window.location.pathname.match(/\/t(\d+)/); if (!topic_match) return;
  var current_topic = topic_match[1];
  var navbar = document.querySelector('.pathname-box');
  if (!current_topic || !navbar) return;
  var forum_selector = navbar.querySelectorAll('.nav');
  var current_forum = forum_selector[forum_selector.length - 1]; if (!current_forum) return;
  var forum_match = current_forum.href.match(/\/f(\d+)/); if (!forum_match) return;
  current_forum = forum_match[1]; if (!current_forum) return;
  if (topic_ids.includes(parseInt(current_topic)) || forum_ids.includes(parseInt(current_forum))) {
    $('.signature_div').filter(function(){ this.style.display = "none" });
  }
  var cat_selector = navbar.querySelectorAll('.nav');
  var current_cat = cat_selector[cat_selector.length - 2]; if (!current_cat) return;
  var cat_match = current_cat.href.match(/\/c(\d+)/); if (!cat_match) return;
  current_cat = cat_match[1]; if (!current_cat) return;
  if (topic_ids.includes(parseInt(current_topic)) || cat_ids.includes(parseInt(current_cat))) {
    $('.signature_div').filter(function(){ this.style.display = "none" });
  }
});

It's the second line, change 4 for the user ID (on its profile, the number on the link).
You can use as many as you want, for example [4, 8, 15, 16, 23, 42] to block the script on different users.

PS: I checked the other problem with this script but I have no idea what's wrong with it, sorry.
avatar
Wecoc
Forumember

Male Posts : 134
Reputation : 94
Language : Catalan, Spanish, English

http://www.mundo-maker.com/

Back to top Go down

Solved Re: Exclude User ID From Javascript

Post by timberella on May 20th 2018, 7:13 am

Yes, @Draxion, and it looks like @Wecoc has provided me with what I was looking for.

Thanks so much, Wecoc, you're always helping me with my Javascript needs, and I really appreciate it!  I'm sure the member who would like to see these signatures will be thrilled, and the rest of us that don't want to see them will also be happy.

I'm sorry to hear that you can't see why the toolbar isn't showing for the Quick Reply editor in IE, but thanks so much for giving it a look.

Cheers.

I'll mark this topic as solved.
avatar
timberella
Forumember

Female Posts : 63
Reputation : 2
Language : English

http://pinkpalace.forumotion.com/

Back to top Go down

Solved Re: Exclude User ID From Javascript

Post by SLGray on May 20th 2018, 10:01 am

Problem solved & topic archived.
Please read our forum rules:  ESF General Rules


When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.

avatar
SLGray
Administrator
Administrator

Male Posts : 43893
Reputation : 3124
Language : English
Location : United States

http://fmthemesdesignteam.forumotion.com/

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum