Looking For Something?

Using shortcodes in theme page templates

All shortcodes can be used as a PHP function, allowing those who would like to edit page templates, create plugins or otherwise use code directly, to include WP Symposium Pro functionality.

A typical use of this is the inclusion of “flags” showing unread messages, friend requests and new alerts relevant to the user.

The following list shows every shortcode in WP Symposium Pro and the related function that you would call.

To the left is the shortcode, and beside it the equivalent function. Following the list, how you se examples of these functions and how to pass options.

Functions

Activity

[wps-activity]wps_activity()
[wps-activity-page]wps_activity_page()
[wps-activity-post]wps_activity_post()
[wps-alerts-activity]wps_alerts_activity()

Calendar

[wps-calendar]wps_calendar()
[wps-calendar-backto]wps_calendar_post()
[wps-calendar-post]wps_calendar_post()

Directory

[wps-directory]wps_directory()
[wps-directory-search]wps_directory_search()

Forums

[wps-forum]wps_forum()
[wps-forum-comment]wps_forum_comment()
[wps-forum-page]wps_forum_page()
[wps-forum-post]wps_forum_post()
[wps-forums]wps_forums()
[wps-forum-backto]wps_forum_backto()
[wps-forum-show-posts]wps_forum_show_posts()
[wps-forum-sharethis]wps_forum_sharethis_insert()

Groups

[wps-group-activity] wps_group_activity()
[wps-group-admin]wps_group_admin()
[wps-group-create] wps_group_create()
[wps-group-delete]wps_group_delete()
[wps-group-description]wps_group_description()
[wps-group-edit]wps_group_edit(
[wps-group-id]wps_group_id()
[wps-group-image] wps_group_image()
[wps-group-join-button]wps_group_join_button()
[wps-group-members]wps_group_members()
[wps-group-post]wps_group_post()
[wps-groups]wps_groups()
[wps-group-title]wps_group_title()
[wps-group-url]wps_group_url()
[wps-my-groups]wps_my_groups()

Members

[wps-close-account]wps_close_account()
[wps-friends]wps_friends()
[wps-friends-add-button]wps_friends_add_button()
[wps-friends-pending]wps_friends_pending()
[wps-friends-status] wps_friends_status()
[wps-gallery] wps_gallery()
[wps-gallery-grid]wps_gallery_grid()
[wps-gallery-list]wps_gallery_list()
[wps-usermeta]wps_usermeta()
[wps-usermeta-button]wps_usermeta_button()
[wps-usermeta-change]wps_usermeta_change()
[wps-usermeta-change-link]wps_usermeta_change_link()

Private Messaging

[wps-alerts-mail]wps_alerts_mail()
[wps-mail] wps_mail()
[wps-mail-backto] wps_mail_backto()
[wps-mail-comment]wps_mail_comment()
[wps-mail-post]wps_mail_post()
[wps-mail-recipients]wps_mail_recipients()
[wps-mail-search]wps_mail_search()
[wps-mail-to-user]wps_mail_to_user_post()

Profile

[wps-avatar]wps_avatar()
[wps-avatar-change]wps_avatar_change()
[wps-avatar-change-link]wps_avatar_change_link()
[wps-display-name]wps_display_name()

Rewards

[wps-badge]wps_badge()
[wps-reward]wps_reward()
[wps-rewards]wps_rewards()

Core/Miscellaneous

[wps-login-form]wps_login_form()
[wps-lounge]wps_lounge()

Passing options

Shortcode options, when used with functions, are passed an array of these options. The options and values are the same as per the shortcodes which you can get elsewhere on this site.

The best way to see how they work is with the following examples, see how the array parameters in the following code represent the shortcode options.

Examples

The following are some examples of how these functions can be used.

Unread mail messages icon

The following PHP code will display a custom flag icon (flag_src), pointing to /mail (flag_url). It also shows the number of unread mail messages if applicable. flag_src is optional.

echo wps_alerts_mail(array(
    'flag_url'=>'/mail',
    'flag_src'=>'/path/to/mail_light.png'
));

New friend request icon

The following PHP code will display a custom flag icon (flag_src), pointing to /friends (flag_url). It also shows the number of pending friendship requests if applicable. flag_src is optional.

echo wps_alerts_friends(array(
    'flag_url'=>'/friends',
    'flag_src'=>'/path/to/friends_light.png'
));

New alerts icon

The following PHP code will display a custom flag icon (flag_src), pointing to /alerts (flag_url), changing the default setting to an icon (style). It also shows the number of new alerts if applicable. flag_src is optional.

echo wps_alerts_activity(array(
    'style'=>'flag',
    'flag_url'=>'/alerts',
    'flag_src'=>'/path/to/flag_light.png'
));

Dropdown list of alerts

The following PHP code will show a drop down list of alerts, passing no parameters, using the default settings.

echo wps_alerts_activity('');

Quick member select dropdown

The following will display a dropdown list that is searchable, allowing the quick selection of a member, and going to their profile page when hitting return.

echo wps_directory_search(array(
    'quick_select' => '1',
    'mode' => 'list',
    'placeholder' => 'Member search...'
));

Core Functions (API)

These functions are available with the core plugin, and can be used by developers as an API when developing other plugins, etc.

Accessing the API

To be able to use the core functions, you need to include the API file, for example, changing the path to match your installation:

require_once('your/path/to/plugins/wp-symposium-pro/core_api.php');

API Functions

Insert Activity Post

Adds a post into the activity stream of a user.

wps_api_insert_activity_post
Returns ID of the new WordPress activity post, or false

  1. The activity post to be inserted.
  2. The WordPress ID of a user as the author of the post.
  3. The WordPress ID of a user as the target of the post
  4. $_POST of any other fields to be used via wps_activity_post_add_hook filter (optional).
  5. $_FILES of any other fields to be used via   wps_activity_post_add_hook filter (optional).

To add an activity post to a member’s activity stream to themselves, shared with their friends, set $c to the same as $b. So, to add an activity post to the member whose WordPress user ID is 99, targetting themselves (ie. shared with just friends) you would use the following:

wps_api_insert_activity_post('The post', 99, 99);

To pass $_POST and $_FILES, you would:

wps_api_insert_activity_post('The post', 99, 99, $my_POST, $my_FILES);

Within the function, the wps_activity_post_add_hook hook is called as with WP Symposium Pro, passing $my_POST and $my_FILES.

Get user’s last active date/time

Gets last active timestamp for a user, optionally formatted .

wps_api_user_last_active
Returns Date/time value, formatted string, or false if no last   active value available.

  1. The WordPress user ID.
  2. Set to false to return date/time value, or a string for   formatting, eg: “Last active: %s ago”.

To get the last active date/time for user 99, formated as “Last active: 1 hour ago” (for example):

wps_api_user_last_active(99, "Last active: %s ago");

 

Sidebar