Skip to main content
Solved

Can you remove the 'create a post' button on the mega menu for non-logged in/not-registered users?

  • January 16, 2025
  • 8 replies
  • 64 views

ryanne.perry

Hi there! I have recently feedback from some of our senior executives regarding the flows of Community when a user is not yet registered or not logged in. One of the main points of contention was from the flow of a non-logged in user pressing the ‘create a post’ button (see screenshot from executive below). 

Has anyone used any custom scripting or know of any workarounds to remove/improve this experience?

 

Best answer by olimarrio

@ryanne.perry here’s one way you could go about this (please add code at your own risk):

<script>
  if (inSidedData.user.role == 'roles.guest') { 
    // Make the widget visible 
  	$('.menu-create-topic').css('display', 'none');
  } 
</script>

 

View original
Did you find this topic helpful?

8 replies

DannyPancratz
Forum|alt.badge.img+7
  • VIP ⭐️⭐️⭐️⭐️⭐️
  • 967 replies
  • January 16, 2025

I’d be shocked if it was not possible to hide this via a third party script. I don’t have the technical chops to do it, but you could ask support. (Please share if you get an answer)

You want to use a third party script because that will allow you to leverage the primary role of the user (roles.guest, I believe) and then conditionally hide the target element. 

I’ve done similar things with various widgets and even the box that shows above the reply box on posts with no replies 

Zero replies box
Show content
<!--START Remove 0 replies box from KB and Community-->
<script>
  var repliesCount = document.getElementsByClassName("qa-total-replies")[0];
  if (repliesCount.innerHTML === "0 Replies") {
   document.getElementById("comments").style.display = "none"
  }
</script>
<!--END remove 0 replies box-->

 

(the script for that in case anyone is looking to do something similar)


ryanne.perry
  • Author
  • Helper ⭐️
  • 82 replies
  • January 16, 2025

Thanks ​@DannyPancratz! I will submit an inquiry to support and let you know if I can find something.


Claudius
  • Contributor ⭐️
  • 1 reply
  • January 17, 2025

As long as the question the user entered doesn’t get lost along the registration flow I don’t see anything bad about having the quickest possible route for visitors with a question to get that posted. I see it very often in communities to allow users to enter their question, then being asked to sign in (and register if not registered already). It’s… a grey UX pattern I would say because once your visitor already invested the time and effort to type in their request they are more likely to go through the final step of registration 😉


olimarrio
Forum|alt.badge.img+4
  • Gainsight Employee ⭐️
  • 408 replies
  • January 17, 2025

Hi ​@ryanne.perry 👋,

Interesting feedback regarding the UX here. You could argue that the ‘Create a Post’ button acts as another CTA and encourages login / registration. It would also be interesting to explore what ​@Claudius suggested in allowing a user to create their topic and then being asked to login / register if they are not already and then posting the topic they’ve created once this is complete.

But in answer to your original question - yes, this is possible using Third Party Scripts (thanks ​@DannyPancratz). I’ll test this on your sandbox and then share the script here shortly.


ryanne.perry
  • Author
  • Helper ⭐️
  • 82 replies
  • January 17, 2025

Thank you ​@Claudius! Great points. I agree, I believe it does act as another CTA and way to drive signups and interaction within the Community (my hands are tied here). 

@olimarrio thank you for the support and look forward to seeing the scripts.


olimarrio
Forum|alt.badge.img+4
  • Gainsight Employee ⭐️
  • 408 replies
  • Answer
  • January 17, 2025

@ryanne.perry here’s one way you could go about this (please add code at your own risk):

<script>
  if (inSidedData.user.role == 'roles.guest') { 
    // Make the widget visible 
  	$('.menu-create-topic').css('display', 'none');
  } 
</script>

 


ryanne.perry
  • Author
  • Helper ⭐️
  • 82 replies
  • January 17, 2025

Thank you ​@olimarrio! Is there typically a lag time for the script to go into effect?


olimarrio
Forum|alt.badge.img+4
  • Gainsight Employee ⭐️
  • 408 replies
  • January 17, 2025

@ryanne.perry with the script above there will be a very small lag time as for the script to work it needs the DOM to be loaded. Once this is loaded the script will run and hide the button.

The alternative method would be to add some custom CSS so that it hides the button for all users and then add a script to remove the custom CSS for everyone except guest users. There will still be a very small lag time for the exact reason above but instead the button will appear momentarily later rather than disappear. It depends what kind of behaviour you’d prefer.

Let me know if you need any more help with this!


Did you find this topic helpful?

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings