Custom Permissions Error Message

By Ed JohnsonEd Johnson

Description

The standard permissions error message that pops up has messages preset by Wikidot. Using a bit of CSS you can customize this message in a way that might better fit the needs of your site.

For example, you have a site that is exposed to the public, but is only edited and maintained by you or a small group of users. The default permissions error message includes a rather generic message that says, "Only site administrators and perhaps selected moderators are allowed to do it." Well, there's no "perhaps" about it in this example! We don't want anyone else editing our page!

Similarly, if an unauthorized user tries to create a new page, the default error message says, "Sorry, you can not create a new page in this category. Only site administrators and perhaps selected moderators are allowed to do it. Sign in as Wikidot user" and contains a link to sign into Wikidot. Again, it would be nice to have a simpler message that relates to our site and removes any references to Wikidot or signing in.

Here is an example of a couple of standard error messages:

permission-error-standard-1.jpg

permission-error-standard-2.jpg

With some simple CSS edits, we can customize the look of these messages:

permission-error-custom.jpg

Code

Add this to your site's custom CSS. Note that some of the colors and margins may need to be edited to match the current theme of your site.

/* Permission Errors
============================== */
/* Title bar of the error window */
#ohandle-1.title {
color: #F5F5F5; /* set the color to match the background color to hide the default text*/
}
#ohandle-1.title:before {
content: "Administrative Use Only"; /* display this content before the title text */
color: darkred; /* change font color if you wish */
font-size: 18px; /* change font size if you wish */
}
 
/* completely hide the paragraph text with the default Wikidot messages */ 
#owindow-1.owindow p {
display: none; 
}
 
/* Hide "Please Note:" text*/
#owindow-1.owindow h1 {
color: white;
}
#owindow-1.owindow h1:before {
content: "Sorry, that option is for administrative use only."; /* display this before the "Please Note" text */
color: black; /* change font color if you wish */
font-size: 18px; /* change font size if you wish */
}

In action

This technique was implemented on this site: mascot-golf (try pressing CTRL-E on the home page to see the customized error block)


Thanks to tsangk for this great snippet: conditional-blocks


text above inserted with:

[[include :snippets:if START |unique=1|type=equal|var1=%%name%%|var2=conditional-blocks]]
**##red|Thanks to tsangk for this great snippet:##** [[[code:conditional-blocks]]]
[[include :snippets:if END]]



Other snippets posted by Ed Johnson


Rate this solution

If you think this solution is useful — rate it up!

rating: +9+x
Add a New Comment
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License