Do NOT Show "Log in to post" Button If User Can't Post to that Category



  • It looks like if a guest is viewing a category that CANNOT be posted to by even registered members, that the button shows, "Log in to post." How do I get rid of that button for categories that registered users can't post to?

    I mean, it would be stupid to show that button and have my user click it, log in, then realize they can't post to the category. 😄

    The highlighted message below the button doesn't need to show either ("There are no topics in this category. Why don't you try posting one?").



  • Or maybe make it say, "Login to view..."


  • Admin

    See, the tricky part here is that we don't know you can't post topics until you log in and we see that you don't have the necessary privileges to post topics.

    Bit of a catch 22 there...



  • @julian well actually, you do in this case. He stated that no one has permission to post. One would insinuate that means no one but admin.

    You can hook the permissions of the category and then unless group X has post permission, then do not show the button whether logged in or not.

    Group X could be selectable and default to registered users.


  • Admin

    Yes, but that is unnecessarily restrictive and assumes people will be using the privilege system in a specific way -- that is, nobody can post to it except admins.

    Our privilege system has it's quirks, but it is highly customisable, and we wouldn't be able to know if we should show the button or not given no information.

    For example let's say I want to have a category that only allows posting if you're a member of group A (and not registered users). If we set this "group X" to registered users, then the button won't show... but you DO want the button to show, just in case once you log in, you are in group A.

    Hope that makes sense.


  • Admin

    I get what you're saying with the group X logic (even if I can't really put it into words), but if I can't explain it in one sentence, it is too complicated and nobody will use it.



  • It's as simple as this: if only admins can post to the category, don't show the "Log in to post" button. Show, instead, "Log in to view" or somesuch.

    If(only_admins) { "Log in to read" } else { "Log in to post" };

    In fact, if you'll tell me where the code is to draw that button, I can probably do this myself.



  • @c-k-lester What if the current guest is an admin? Then it should be "Log in to post" but he is not connected yet so we don't know.


  • Admin

    @Telokis said in Do NOT Show "Log in to post" Button If User Can't Post to that Category:

    @c-k-lester What if the current guest is an admin? Then it should be "Log in to post" but he is not connected yet so we don't know.

    Correct, therein lies the problem.

    If you are using a custom theme, then we can change the button to whatever you want it to say (or even remove it altogether)



  • @Telokis True. But the conditional as written is how I want it to behave, because the behavior is for the user, not the admin.


  • Community Rep

    Use custom css in the admin appearance tab like this, using the actual category number you want to hide:

    .page-category-16 [component="category/post/guest"] {
      display: none;
    }
    

    Really, I feel like the Login to Post is for posting to the forum in general, not necessarily to the category being viewed.


Log in to reply
 


Star

Looks like your connection to NodeBB was lost, please wait while we try to reconnect.