Hide content when a user is not logged In

plugins

(Joey Bryan) #1

Our goal is to increase user sign up’s by hiding certain content and instead showing a sign up form / button.

I’ve got a local dev environment up and running and have been playing around with plugins / plugin creation.

I’m thinking of extending making some changes to: GitHub - discourse/discourse-spoiler-alert: A plugin for discourse to hide spoilers behind the spoiler-alert jQuery plugin
in which I would add the sign up text hidden bellow the block.

I was thinking of using Discourse.User.current() on initialize to show either the “sign up” block or “spoiler block”

Am I on the right track or is there a simpler way of going about this?


(Mittineague) #2

Would the “require login” Setting do what you’re wanting?


(Simon Cossar) #3

It sounds like you are on the right track. It would be nice if there was a ‘logged-in’ class added to the body when a user logged in.


(Joey Bryan) #4

We just want certain “snippets” on a page to be hidden rather than an entire topic.


(Joey Bryan) #5

So my plan has worked (yay!), the only issue I have is adding the login button. I’d like the login button to popup the login modal rather than taking the user to a new page.

Is there a method for rendering a button via a plugin? I’m currently adding the other content through jsonML.