TXP Plugin: ign_password_protect

I had a need for password protection for a project I’ve been working on, and the limited functionality of Textpattern’s existing <txp:password_protect /> simply wasn’t cutting it for me.

It seemed there were some others that were looking for some similar functionality. I wasn’t really in the mood to write my own user management piece, so I looked at the existing authentication for the admin area in TXP. And I thought that rather than hack the source, I’d make it a plug-in to share.

Without further ado, please give a warm welcome to:

ign_password_protect.txt

Basic usage:
ign_password_protect features two three tags currently:
<txp:ign_password_protect></txp:ign_password_protect>
<txp:ign_logged_user />

<txp:ign_password_protect></txp:ign_password_protect>

use to password protect part or all of a txp website against users in the txp_user database (on the site_admin tab).
can be used in page or form templates, or even directly within an article.

Accepted parameters:

privs: comma separated list of privilege levels to compare against. If omitted, plugin simply
checks for account existence (including privs = None).

err_msg: replaces error message on bad logins

login_msg: use this to set the greeting message that is displayed above the form

class: use this to set the class assigned to the div containing the form; default value is ign_login

remember: boolean to display checkbox for “remember me”, set to 1 or true to display check box (and set persistent cookie)
set to anything else or omit entirely to disable.

login_type: option to control how login is requested. Set to “page” to use browser’s authentication dialog.
Omit or set to anything else to use inline form element.
Default is inline.

<txp:ign_logged_user />

Displays logged in user name with link to log out if logged in.

Accepted parameters:

logged_msg: replaces default “not logged in” message.

Update 6.15.05: Login form now returns you to the current page as opposed to the index. Also added login_type parameter to allow for browser-based logins. See above for usage.

See it in action here – log in at the right using username=“demo” and password=“38v2qj”.