Home  ›  Template Tags  ›  PM Template Tags

PM Template Tags

The following template tags are used to output Private Messaging information.

Before using any of these template tags, go to Forum ☛ Configuration ☛ Code and Query Optimisation and turn on the support for ‘PM’ Template tags

Unread PMs

This template tag will display (or return) the number of unread PMs in the current users PM inbox. A link to the users PM inbox can also be displayed.

The default text is “You have # PM(s) in your inbox.”. The word ‘inbox’ will be a hyperlink to the users PM inbox. If the user is a guest or does not have PM privileges, the default text is “You do not have PM privileges”. The default text for users with no PM privileges can be suppressed when using the default text.

If the PM data is returned instead of displayed, it will be in an array with keys of ‘count’ and ‘url’. A count of -1 will indicate no PM permissions.

sf_pm_tag($display=true, $usersonly=false)

Possible arguments to the template tag are:

ParameterDescriptionTypeDefault
$displayDisplay the PM count with default text (returns the data if false).Booleantrue
$usersonlyDisplay privilege message to user/guests without PM permissions.Booleanfalse

User specified styles available for template tag output are:

StylesAffected Output
p.sfpmcountStyles the <p> element that wraps the pm inbox info.

An example usage of the template tag is:

<?php sf_pm_tag(true, false); ?>

Send PM Link

This template tag will display a link to allow users to send a PM to a registered user with PM permissions. This template tag is normally displayed on non forum pages.

The template tag will display a default string of ‘Send PM’ unless an alternate text string is passed to the template tag. If you choose to pass the text string to the template tag, be sure to include a **%**% somewhere in the text string to indicate where you want the link placed.

sf_sendpm_tag($userid, $text='')

Possible arguments to the template tag are:

ParameterDescriptionTypeDefault
$useridWordPress user ID of the user to send a PM to.Integer-
$textAlternate text message to display.String-

An example usage of the template tag is:

<?php
$text = '<a href="%%" title="Send PM">Send PM</a>';
 sf_sendpm_tag(32, $text);
?>

Article written by steve on January 24, 2010 and last modified by steve on May 15, 2011