模板標籤參考Codex Home → Developer Resources → Template Tag Reference
Template Tag Reference
This page is currently undergoing review and updating. References marked with ? have been reviewed for current accuracy.
General Template Tags
bp_get_loggedin_user_nav()
Deprecated
Uses the $bp->bp_nav global to render out the navigation within a BuddyPress install.
Each component adds to this navigation array within its own [component_name]_setup_nav() function.This navigation array is the top level navigation, so it contains items such as:
[Blog, Profile, Messages, Groups, Friends] …The function will also analyze the current component the user is in, to determine whether or not to highlight a particular nav item.
Since 1.1.0
bp_get_displayed_user_nav()
Uses the $bp->bp_users_nav global to render out the user navigation when viewing another user other than yourself.
Since 1.1.0
bp_get_options_nav()
Uses the $bp->bp_options_nav global to render out the sub navigation for the current component.
Each component adds to its sub navigation array within its own [component_name]_setup_nav() function.This sub navigation array is the secondary level navigation, so for profile it contains: [Public, Edit Profile, Change Avatar] The function will also analyze the current action for the current component to determine whether or not to highlight a particular sub nav item.@uses bp_get_user_nav() Renders the navigation for a profile of a currently viewed user.
Since 1.0.0
bp_get_options_title()
Deprecated
bp_site_name()
Returns the 『Site Title』 set in Settings > General.
Since 1.0.0
bp_is_home()
Deprecated since 1.5. Use bp_is_my_profile() instead.
Is the current page part of the profile of the logged-in user? Will return true for any subpage of the logged-in user』s profile, e.g. http://example.com/members/joe/friends/.
bp_last_activity()
Output the 「active [x days ago]」 string for a user.
See bp_get_last_activity() for a description of parameters.
Since 1.0.0
bp_user_link()
Deprecated. Use bp_displayed_user_domain() instead.
bp_get_loggedin_user_link()
Get the link for the logged-in user』s profile.
Since 1.0.0
bp_loggedinuser_link()
Output the link for the logged-in user』s profile.
Since 1.2.4
bp_get_displayed_user_link()
Get the link for the displayed user』s profile.
Since 1.0.0
bp_core_get_wp_profile()
Deprecated since 1.5.0.
bp_get_profile_header()
Deprecated since 1.7.0.
bp_exists()
Deprecated since 1.7.0.
bp_format_time()
Format a date based on a UNIX timestamp.
This function can be used to turn a UNIX timestamp into a properly formatted (and possibly localized) string, useful for outputting the date & time an action took place.
Not to be confused with `bp_core_time_since()`, this function is best used for displaying a more exact date and time vs. a human-readable time.
This function may be improved or removed at a later date, as it is hardly used and adds an additional layer of complexity to calculating dates and times together with timezone offsets and i18n.
Since 1.1.0
bp_word_or_name()
Select between two dynamic strings, according to context. This will display either a word, or a name to provide better context. for example, 「My friends」 or 「Bob』s friends」
This function can be used in cases where a phrase used in a template will differ for a user looking at his own profile and a user looking at another user』s profile (eg, 「My Friends」 and 「Joe』s Friends」). Pass both versions of the phrase, and bp_word_or_name() will detect which is appropriate, and do the necessary argument swapping for dynamic phrases.
Since 1.0.0
bp_get_plugin_sidebar()
Deprecated since 1.7.0.
This will try and find the file plugin-sidebar.php and display it if it』s found.
bp_is_page()
Deprecated since 1.7.0.
bp_is_blog_page()
Is this a blog page, ie a non-BP page?
You can tell if a page is displaying BP content by whether the current_component has been defined.
True if it』s a non-BP page, false otherwise.
Since 1.0.0
bp_page_title()
Deprecated since 1.5.0. Use wp_title()
bp_get_page_title()
Deprecated since 1.5.0. Use wp_title()
bp_styles()
Deprecated
bp_has_custom_signup_page()
Do we have a working custom sign up page?
True if page and template exist, false if not.
Since 1.5.0
bp_signup_page()
Output the URL to the signup page.
Since 1.0.0
bp_has_custom_activation_page()
Do we have a working custom activation page?
True if page and template exist, false if not.
Since 1.5.0
bp_activation_page()
Output the URL of the activation page.
Since 1.0.0
bp_search_form()
Deprecated since 1.1.0.
bp_search_form_action()
Return the 「action」 attribute for search forms.
Since 1.0.0
bp_search_form_type_select()
bp_login_bar() Removed/deprecated
bp_profile_wire_can_post()
This is deprecated, for more info, see the BuddyPress Backwards Compatibility plugin. Deprecated
bp_nav_items()
Deprecated This is deprecated, you should put these navigation items in your template header.php for easy editing.
bp_custom_profile_boxes()
Deprecated
bp_custom_profile_sidebar_boxes()
Deprecated
bp_get_userbar()
Deprecated
bp_get_optionsbar()
Deprecated
bp_is_directory()
Is this a component directory page?
True if the current page is a component directory, otherwise false.
Since 1.0.0
bp_create_excerpt()
Cuts a string to the length of $length and replaces the last characters with the ending if the text is longer than length.
This function is borrowed from CakePHP v2.0, under the MIT license. See http://book.cakephp.org/view/1469/Text#truncate-1625
Since 1.0.0
Fakes an excerpt on any content. Will not truncate words.
bp_is_serialized()
Checks to see if the data passed has been serialized.
bp_rewind_site_members
bp_has_site_members
bp_the_site_member
bp_site_members
bp_site_members_pagination_count
bp_get_site_members_pagination_links
bp_site_members_pagination_links
bp_get_the_site_member_user_id
bp_the_site_member_user_id
bp_get_the_site_member_avatar
bp_the_site_member_avatar
bp_get_the_site_member_link
bp_the_site_member_link
bp_get_the_site_member_name
bp_the_site_member_name
bp_get_the_site_member_last_active
bp_the_site_member_last_active
bp_get_the_site_member_registered
bp_the_site_member_registered
bp_the_site_member_add_friend_button
bp_get_the_site_member_total_friend_count
bp_the_site_member_total_friend_count
bp_the_site_member_random_profile_data
bp_the_site_member_hidden_fields
bp_directory_members_search_form
bp_home_blog_url
BP Member/User tags
bp_displayed_user_id()
bp_current_user_id()
bp_loggedin_user_id()
bp_core_get_user_domain() returns url to user account given a user id 『bp_loggedin_user_id』
bp_core_get_userlink() returns a fully rendered link to users account
bp_displayed_user_domain()
bp_loggedin_user_domain()
bp_user_fullname()
bp_displayed_user_fullname()
bp_get_loggedin_user_fullname()
bp_loggedin_user_fullname()
BP Component & Action checks
bp_current_component()
bp_current_action()
bp_action_variables()
Avatar Template Tags
bp_has_options_avatar()
Check to see if there is an options avatar. An options avatar is an avatar for something
like a group, or a friend. Basically an avatar that appears in the sub nav options bar.
bp_get_options_avatar()
bp_comment_author_avatar()
bp_post_author_avatar()
bp_loggedin_user_avatar()
bp_get_loggedin_user_avatar()
bp_displayed_user_avatar()
bp_get_displayed_user_avatar()
bp_avatar_admin_step()
bp_get_avatar_admin_step()
bp_avatar_to_crop()
bp_get_avatar_to_crop()
bp_avatar_to_crop_src()
bp_get_avatar_to_crop_src()
bp_avatar_cropper()
Signup Template Tags
bp_signup_username_value
bp_get_signup_username_value
bp_signup_email_value
bp_get_signup_email_value
bp_signup_with_blog_value
bp_get_signup_with_blog_value
bp_signup_blog_url_value
bp_get_signup_blog_url_value
bp_get_signup_blog_title_value
bp_signup_blog_title_value
bp_get_signup_blog_privacy_value
bp_signup_blog_privacy_value
bp_get_signup_avatar_dir_value
bp_signup_avatar_dir_value
bp_get_current_signup_step
bp_current_signup_step
bp_get_signup_avatar
bp_signup_avatar
Section under review/editing see below for more up to date references.
is_ functions
These is_ functions are used to determine the type of page currently being served within the template.
bp_is_user()
Used to determine if the current page is a user page.
Returns:
TRUE if current page is a user page
FALSE otherwise
bp_is_user_profile()Used to determine if the current page is a profile screen.
Returns:
TRUE if current page is a profile page
FALSE otherwise
bp_is_activity()Used to determine if the current page is the activity page.
Returns:
TRUE if current page is the activity page
FALSE otherwise
bp_is_blogs()Used to determine if the current page is the blogs page.
Returns:
TRUE if current page is the blogs page
FALSE otherwise
bp_is_wire()Used to determine if the current page is a wire page.
Returns:
TRUE if current page is a wire page
FALSE otherwise
bp_is_messagesUsed to determine if the current page is a messages page.
Returns:
TRUE if current page is a messages page
FALSE otherwise
bp_is_friends()Used to determine if the current page is a friends page.
Returns:
TRUE if current page is a friends page
FALSE otherwise
bp_is_group()Used to determine if the current page is the groups page.
Returns:
TRUE if current page is the groups page
FALSE otherwise
bp_is_settings_componentUsed to determine if the current page is the user settings page.
Returns:
TRUE if current page is the user settings page page
FALSE otherwise
bp_is_my_activityUsed to determine if the current page is the my activity page.
Returns:
TRUE if current page is the my activity page
FALSE otherwise
bp_is_friends_activity()Used to determine if the current page is a friends activity page.
Returns:
TRUE if current page is a friends activity page
FALSE otherwise
bp_is_profile_edit()Used to determine if the current page is the profile edit page.
Returns:
TRUE if current page is the profile edit page
FALSE otherwise
bp_is_change_avatar()Used to determine if the current page is the change avatar page.
Returns:
TRUE if current page is the change avatar page
FALSE otherwise
bp_is_group_single()Used to determine if the current page is a single group page.
Returns:
TRUE if current page is a single group page
FALSE otherwise
bp_is_group_home()Used to determine if the current page is a group homepage.
Returns:
TRUE if current page is a group homepage
FALSE otherwise
bp_is_group_create()Used to determine if the current page is a group create page.
Returns:
TRUE if current page is a group create page
FALSE otherwise
bp_is_group_admin_page()Used to determine if the current page is a group admin page.
Returns:
TRUE if current page is a group admin page
FALSE otherwise
bp_is_group_forum()Used to determine if the current page is a group forum page.
Returns:
TRUE if current page is a group forum page
FALSE otherwise
bp_is_group_forum_topic()Used to determine if the current page is a group form topic page.
Returns:
TRUE if current page is a group forum topic page
FALSE otherwise
bp_is_group_membersUsed to determine if the current page is a group members page.
Returns:
TRUE if current page is a group members page
FALSE otherwise
bp_is_group_invites()Used to determine if the current page is a group invite page.
Returns:
TRUE if current page is a group invite page
FALSE otherwise
bp_is_group_leave()Used to determine if the current page is a 』leave the group』 page.
Returns:
TRUE if current page is a 』leave the group』 page
FALSE otherwise
bp_is_my_blogsUsed to determine if the current page is the my blogs page.
Returns:
TRUE if current page is the my blogs page
FALSE otherwise
bp_is_create_blog()Used to determine if the current page is the 』create a blog』 page.
Returns:
TRUE if current page is 』create a blog』 page
FALSE otherwise
bp_is_friends_screen()Used to determine if the current page is the friends page.
Returns:
TRUE if current page is the friends page
FALSE otherwise
bp_is_friend_requests()Used to determine if the current page is the friend requests page.
Returns:
TRUE if current page is the friend requests page
FALSE otherwise
bp_is_messages_inbox()Used to determine if the current page is the messages inbox page.
Returns:
TRUE if current page the messages inbox page
FALSE otherwise
bp_is_messages_sentbox()Used to determine if the current page is the messages sentbox page.
Returns:
TRUE if current page is the messages sentbox page
FALSE otherwise
bp_is_messages_conversation()Used to determine if the current page is a single messages conversation.
Returns:
TRUE if the current page is a single messages thread
FALSE otherwise
bp_is_notices()Used to determine if the current page is the notices page.
Returns:
TRUE if current page is the notices page
FALSE otherwise
bp_is_messages_compose_screen()Used to determine if the current page is the message compose page.
Returns:
TRUE if current page is the message compose page
FALSE otherwise
bp_is_register_page()Used to determine if the current page is the registration page.
Returns:
TRUE if current page is the registration page
FALSE otherwise
bp_is_activation_page()Used to determine if the current page is the activation page.
Returns:
TRUE if current page is the activation page
FALSE otherwise
Conditional template tags allow you to show specific content on specific pages. The following tags are available in BuddyPress (1.2+):
is_buddypress()
A generic check for buddypress screens.
Returns:
TRUE if current screen is a BP one
FALSE otherwise
bp_is_user()
Used to determine if the current page is a user page.
Returns:
TRUE if current page is a user page
FALSE otherwise
bp_is_user_profile()
Used to determine if the current page is a profile screen.
Returns:
TRUE if current page is a profile page
FALSE otherwise
bp_is_my_profile()
Used to determine if this is a profile component screen
Returns:
TRUE if current page is a profile page
FALSE otherwise
bp_is_blog_page()
A catch all for a WP blog page in BP.
bp_is_directory()
bp_is_serialized($data) – checks to see if $data is serialized
bp_is_front_page()
bp_is_activity_front_page()
bp_is_page($page) // deprecated 1.7 use bp_is_current_component( 『activity』 )
bp_is_current_component( 『activity』 ) ?
bp_is_active( $component ) – checks if a BP $component is active ?
bp_is_profile_component()
bp_is_activity_component()
bp_is_blogs_component()
bp_is_messages_component()
bp_is_friends_component()
bp_is_groups_component()
bp_is_settings_component()
bp_is_user_activity()
bp_is_user_friends_activity()
bp_is_activity_permalink() // deprecated 1.5 use bp_is_single_activity()
bp_is_user_profile()
bp_is_profile_edit()
bp_is_change_avatar()
bp_is_user_groups()
bp_is_group()
bp_is_group_home()
bp_is_group_create()
bp_is_group_admin_page()
bp_is_group_forum()
bp_is_group_activity()
bp_is_group_forum_topic()
bp_is_group_forum_topic_edit()
bp_is_group_members()
bp_is_group_invites()
bp_is_group_membership_request()
bp_is_group_leave()
bp_is_group_single()
bp_is_user_blogs()
bp_is_user_recent_posts()
bp_is_user_recent_commments()
bp_is_create_blog()
bp_is_user_friends()
bp_is_friend_requests()
bp_is_user_messages()
bp_is_messages_inbox()
bp_is_messages_sentbox()
bp_is_notices()
bp_is_messages_compose_screen()
bp_is_single_item()
bp_is_activation_page()
bp_is_register_page()
If you wanted to see if this was a single group page, in your template you could do:
Show this on group home pages
Or if you wanted to show something on every single group page, regardless if it was the home page or not:
Show this on all single group pages
There are no specific checks on group names etc yet, but you can do this:
This is my-group