How to find out if user is logged in and insert some js

(Non-technical User) #1

Hope someone can help me with this.

I want to insert a script to ask our members to subscribe to a newsletter. But I want this only to be shown for members.

I tried doing this using jQuery in Admin > Customize > CSS/HTML >

{ $('<script>')
    .attr('type', 'text/javascript')
    .text('(function (w,i,d,g,e,t,s) {w[d] = w[d]||[];t= i.createElement(g);
    t.async=1;t.src=e;s=i.getElementsByTagName(g)[0];s.parentNode.insertBefore(t, s);
  })(window, document, '_gscq','script','//');')
else { //Do nothing or show someother message

But it doesn’t seem to work. No errors on the console too. Can someone help please?

(Dean Taylor) #2

You are not escaping the quotes in <script> tag text (you need to), you have an extra closing brace }.

(Non-technical User) #3

Thank you for pointing out, that fixed it. Is it possible to get the trust level of a user using javascript?

(Dean Taylor) #4

That question would be best asked in a new topic

(Rafael dos Santos Silva) #5