2. Hooks Reference

bad_password

Synopsis: 

bad_password( $arg );

Check the given password, and either return a string explaining why the password is bad, or undef if the password is okay.

Arguments: 

$arg

Hashref containing at least a password element. Can also contain a u object and user, name, and e-mail elements.

Source: 

  • cgi-bin/ljprotocol.pl
  • htdocs/changepassword.bml
  • htdocs/create.bml
  • htdocs/update.bml
  • ssldocs/changepassword.bml
canonicalize_url

Synopsis: 

canonicalize_url( $url );

Cleans up a URL into its canonical form.

Arguments: 

$url

URL to be cleaned.

Source: 

  • bin/maint/stats.pl
emailconfirmed

Synopsis: 

emailconfirmed( $dbarg $u );

After a user has confirmed their e-mail address, this hook is called with a dbs/dbh and a user object. This is useful to update a database alias table which you also have your mail system using for address lookups.

Arguments: 

$dbarg

Either a dbs or dbh resource object.

$u

User object.

Source: 

  • htdocs/register.bml
login_add_opts

Synopsis: 

login_add_opts( %args );

Appends options to the cookie value. Each option should be short, and preceded by a period.

Arguments: 

%args

Keys

  • u — User object.
  • form — Login form elements.
  • opts — Hash reference of options to append to login cookie.

Source: 

  • htdocs/login.bml
login_formopts

Synopsis: 

login_formopts( %args );

Returns extra HTML for login options on login.bml.

Arguments: 

%args

Hash of arguments.

Keys

  • ret — Scalar return reference.

Source: 

  • htdocs/login.bml
modify_login_menu

Synopsis: 

modify_login_menu( %args );

Modifies or resets entirely the web menu data structure that is sent to the client.

Arguments: 

%args

Hash of arguments.

Keys

  • menu — Menu item.
  • u — User object.
  • dbs — Resource object.
  • user — Username string.

Source: 

  • cgi-bin/ljprotocol.pl
name_caps

Synopsis: 

name_caps( $cap );

Returns the long name of the given capability bit.

Arguments: 

$cap

Capability bit to check.

Source: 

  • cgi-bin/ljlib.pl
  • cgi-bin/ljcapabilities.pl
name_caps_short

Synopsis: 

name_caps_short( $cap );

Returns the short name of the given capability bit.

Arguments: 

$cap

Capability bit to check.

Source: 

  • cgi-bin/ljlib.pl
  • cgi-bin/ljcapabilities.pl
post_changepassword

Synopsis: 

post_changepassword( %args );

Action to take after changing password, before HTML is sent to to client (possibly to print HTTP headers directly).

Arguments: 

%args

Hash of arguments.

Keys

  • u — User object.
  • dbs — Resource object.
  • newpassword — New password.
  • oldpassword — Old password.

Source: 

  • htdocs/changepassword.bml
  • ssldocs/changepassword.bml
post_create

Synopsis: 

post_create( %args );

Action to take after creating an account.

Arguments: 

%args

Hash of arguments.

Keys

  • dbs — Resource object.
  • user — Username string.
  • userid — Integer
  • code — Auth code, if in use.

Source: 

  • cgi-bin/ljlib.pl
post_login

Synopsis: 

post_login( %args );

Action to take after logging in, before HTML is sent to to client (possibly to print HTTP headers directly).

Arguments: 

%args

Hash of arguments.

Keys

  • u — User object.
  • form — Hash of form elements.
  • expiretime — Used for cookies. Can either be a Unix timestamp, or '0' for session cookies.

Source: 

  • htdocs/login.bml
  • htdocs/talkread_do.bml
set_s2bml_lang

Synopsis: 

set_s2bml_lang( $ctx $langref );

Given an S2 Context, return the correct BML language id.

Arguments: 

$ctx

S2 Context.

$langref

Language id reference.

Source: 

  • cgi-bin/LJ/S2.pm
userinfo_html_by_user

Synopsis: 

userinfo_html_by_user( %args );

Extra HTML to show next to username & id on userinfo.bml

Arguments: 

%args

Hash of arguments.

Keys

  • ret — Scalar return reference.
  • u — User object.

Source: 

  • htdocs/userinfo.bml
userinfo_rows

Synopsis: 

userinfo_rows( %args );

Returns a two-element arrayref for a row on a userinfo page, containing first the left side label, then the body.

Arguments: 

%args

Hash of arguments.

Keys

  • dbr — Resource Object (read-only).
  • u — User object
  • remote — Remote user object.

Source: 

  • htdocs/userinfo.bml
validate_get_remote

Synopsis: 

validate_get_remote( %args );

This hook lets you ignore the remote user's cookies or flag them as intentionally forged to LJ::get_remote(). If you return a true value, no action is taken. If you return false, LJ::get_remote() returns undef. You can optionally set $criterr to something true as well.

Arguments: 

%args

Hash of arguments

Keys

  • user — May be an empty string or undef.
  • userid — May be 0
  • dbs — Resource object
  • caps — Capabilities.
  • criterr — Scalar error reference.
  • cookiesource — Sub reference which takes a cookie name and returns its value.

Source: 

  • cgi-bin/ljlib.pl