Actions/动作
- asgarosforum_after_post_author
- asgarosforum_after_post_message
- asgarosforum_after_add_topic_submit
- asgarosforum_after_add_post_submit
- asgarosforum_after_edit_post_submit
- asgarosforum_after_topic_approve
- asgarosforum_{current_view}_custom_content_top
- asgarosforum_{current_view}_custom_content_bottom
- asgarosforum_editor_custom_content_bottom
- asgarosforum_statistics_custom_element
- asgarosforum_statistics_custom_content_bottom
- asgarosforum_admin_show_custom_category_data
- asgarosforum_before_delete_post
- asgarosforum_before_delete_topic
- asgarosforum_after_delete_post
- asgarosforum_after_delete_topic
- asgarosforum_custom_forum_column
- asgarosforum_custom_topic_column
- asgarosforum_custom_profile_content
- asgarosforum_custom_profile_menu
- asgarosforum_custom_header_menu
- asgarosforum_prepare_{current_view}
- asgarosforum_wp_head
- asgarosforum_bottom_navigation
- asgarosforum_usergroup_{ID}_add_user
- asgarosforum_usergroup_{ID}_remove_user
- asgarosforum_prepare
- asgarosforum_breadcrumbs_{current_view}
- asgarosforum_content_top
- asgarosforum_content_header
- asgarosforum_after_category
- asgarosforum_after_forum
- asgarosforum_after_topic
- asgarosforum_after_post
- asgarosforum_content_bottom
- asgarosforum_add_admin_submenu_page
- asgarosforum_execution_check
- asgarosforum_enqueue_css_js
- asgarosforum_profile_row
- asgarosforum_after_add_reaction
- asgarosforum_after_remove_reaction
- asgarosforum_after_update_reaction
- asgarosforum_after_post_author
- asgarosforum_after_post_message
- asgarosforum_after_add_topic_submit
- asgarosforum_after_add_post_submit
- asgarosforum_after_edit_post_submit
- asgarosforum_after_topic_approve
- asgarosforum_{current_view}_custom_content_top
描述
在 Asgaros Forum 的特定视图上执行一些操作。代码将在头部之前执行。
可用视图:
| view_name | Description |
|---|---|
| overview | 所有论坛版块的概览页面/Overview page of all forums |
| forum | 单个论坛版块的页面/Page with a single forum |
| topic | 单个话题的页面/Page with a single topic |
| post | 仅用于某个帖子的短代码/Only used in the single post shortcode |
| editpost | 编辑某个帖子/Edit a post |
| addpost | 添加一个帖子/Add a post |
| addtopic | 添加一个话题/Add a topic |
| movetopic | 移动某个话题/Move a topic |
| search | 搜索结果页面/Page with results of search |
| subscription | 某个用户所有的订阅概览/Overview of all subscriptions of a user |
| profile | Asgaros Forum 个人资料页面/Page with profile of Asgaros Forum |
| history | 个人资料用户历史页面/Page with users history in profile |
| members | 会员列表页面/Page with list of members |
| activity | 论坛动态页面/Activity page of Forum |
| unread | 未读帖子页面/Page with unread posts |
| unapproved | 未审核/帖子/话题的页面/Page with unapproved posts/topics |
| reports | 被举报帖子/话题的页面/page with reported posts/topics |
用法
<?php
add_action('asgarosforum_{current_view}_custom_content_top', 'function_name');
?>
示例
<?php
// Add action to print message on top of the memberslist
add_action('asgarosforum_members_custom_content_top', 'add_welcome_message');
// Print welcome message
function add_welcome_message(){
echo '<h2>Welcome to the List of all Members</h2>';
}
?>
资源
- asgarosforum_{current_view}_custom_content_bottom
- asgarosforum_editor_custom_content_bottom
- asgarosforum_statistics_custom_element
- asgarosforum_statistics_custom_content_bottom
- asgarosforum_admin_show_custom_category_data
- asgarosforum_before_delete_post
- asgarosforum_before_delete_topic
- asgarosforum_after_delete_post
- asgarosforum_after_delete_topic
- asgarosforum_custom_forum_column
- asgarosforum_custom_topic_column
- asgarosforum_custom_profile_content
- asgarosforum_custom_profile_menu
- asgarosforum_custom_header_menu
- asgarosforum_prepare_{current_view}
- asgarosforum_wp_head
- asgarosforum_bottom_navigation
- asgarosforum_usergroup_{ID}_add_user
- asgarosforum_usergroup_{ID}_remove_user
- asgarosforum_prepare
- asgarosforum_breadcrumbs_{current_view}
- asgarosforum_content_top
描述
在 Asgaros Forum 上执行一些操作。代码将在头部之前执行。
用法
<?php
add_action('asgarosforum_post_custom_content_top', 'function_name');
?>
示例
<?php
// Add action to print message on top of the forum
add_action('asgarosforum_post_custom_content_top', 'add_welcome_message');
// Print welcome message
function add_welcome_message(){
echo '<h2>Welcome to our Forum</h2>';
}
?>
资源
asgarosforum_content_header
描述
在内容标题之后执行一些操作
用法
<?php
add_action('asgarosforum_content_header', 'function_name');
?>
示例
<?php
// Add action to print information after header
add_action('asgarosforum_content_header', 'add_information');
// Print information
function add_information(){
echo '<div class="forum-notification">Please read the forum rules before creating a topic.</div>';
}
?>
资源
- asgarosforum_after_category
- asgarosforum_after_forum
- asgarosforum_after_topic
- asgarosforum_after_post
- asgarosforum_content_bottom
- asgarosforum_add_admin_submenu_page
- asgarosforum_execution_check
- asgarosforum_enqueue_css_js
- asgarosforum_profile_row
- asgarosforum_after_add_reaction
- asgarosforum_after_remove_reaction
- asgarosforum_after_update_reaction
过滤器
- asgarosforum_filter_username
- asgarosforum_filter_login_message
- asgarosforum_filter_post_username
- asgarosforum_filter_post_content
- asgarosforum_filter_post_shortcodes
- asgarosforum_filter_editor_settings
- asgarosforum_filter_editor_buttons
- asgarosforum_filter_get_posts
- asgarosforum_filter_get_threads
- asgarosforum_filter_get_posts_order
- asgarosforum_filter_get_threads_order
- asgarosforum_filter_notify_global_topic_subscribers_message
- asgarosforum_filter_notify_topic_subscribers_message
- asgarosforum_filter_notify_mentioned_user_message
- asgarosforum_filter_insert_custom_validation
- asgarosforum_filter_subject_before_insert
- asgarosforum_filter_content_before_insert
- asgarosforum_filter_before_post_submit
- asgarosforum_filter_before_edit_post_submit
- asgarosforum_filter_before_topic_submit
- asgarosforum_filter_widget_title_length
- asgarosforum_widget_excerpt_length
- asgarosforum_subscriber_mails_new_post
- asgarosforum_subscriber_mails_new_topic
- asgarosforum_filter_error_message_require_login
- asgarosforum_filter_user_groups_taxonomy_name
- asgarosforum_filter_avatar_size
- asgarosforum_filter_profile_header_image
- asgarosforum_filter_profile_link
- asgarosforum_filter_history_link
- asgarosforum_filter_show_header
- asgarosforum_filter_header_menu
- asgarosforum_filter_forum_menu
- asgarosforum_filter_topic_menu
- asgarosforum_filter_post_menu
- asgarosforum_filter_members_link
- asgarosforum_filter_automatic_topic_title
- asgarosforum_filter_automatic_topic_content
- asgarosforum_filter_widget_avatar_size
- asgarosforum_filter_get_sticky_topics_order
- asgarosforum_user_replacements
- asgarosforum_seo_trailing_slash
- asgarosforum_reactions
- asgarosforum_widget_recent_posts_custom_content
- asgarosforum_widget_recent_topics_custom_content
- asgarosforum_title_separator
- asgarosforum_filter_profile_row
- asgarosforum_signature
- asgarosforum_filter_meta_post_type
- asgarosforum_filter_upload_folder
- asgarosforum_filter_username
描述
将用户名更改为自定义名称。
参数
$user_name
将在论坛中显示的用户名。
$user_object
用户的用户对象。
用法
<?php
add_filter('asgarosforum_filter_username', 'function_name', 10, 2);
?>
示例
<?php
// Add filter to customize username
add_filter('asgarosforum_filter_username', 'show_first_name', 10, 2);
function show_first_name($username, $user_object){
// get first name of user
$new_username = $user_object->first_name;
// Set default name if user didn't set a first name
if (empty($new_username)){
$new_username = $username;
}
return $new_username;
}
?>
资源
- asgarosforum_filter_login_message
- asgarosforum_filter_post_username
描述
在帖子中更改用户名。你也可以用它在用户名后添加一些其他信息
用法
<?php
add_filter('asgarosforum_filter_post_username', 'function_name', 10, 2);
?>
示例
<?php
// Add filter to customize username
add_filter('asgarosforum_filter_post_username', 'add_custom_value', 10, 2);
function add_custom_value($username, $user_id){
// Get meta data of user
$user_meta=get_userdata($user_id);
// Get user roles of user and create string
$user_roles= implode(', ', $user_meta->roles) . " ";
// Add user role to username
$username = $username . $user_roles;
// Return string to render
return $username;
}
?>
资源
- asgarosforum_filter_post_content
- asgarosforum_filter_post_shortcodes
- asgarosforum_filter_editor_settings
- asgarosforum_filter_editor_buttons
- asgarosforum_filter_get_posts
- asgarosforum_filter_get_threads
- asgarosforum_filter_get_posts_order
- asgarosforum_filter_get_threads_order
- asgarosforum_filter_notify_global_topic_subscribers_message
- asgarosforum_filter_notify_topic_subscribers_message
- asgarosforum_filter_notify_mentioned_user_message
- asgarosforum_filter_insert_custom_validation
- asgarosforum_filter_subject_before_insert
- asgarosforum_filter_content_before_insert
- asgarosforum_filter_before_post_submit
描述
在发布之前调整帖子或取消提交。
参数
$add_post
包含帖子所有信息的数组:
$add_post = array(
'topic' => $this->asgarosforum->current_topic, // topic id
'forum' => $this->asgarosforum->current_forum, // forum id
'content' => $this->data_content, // content of the post
'author' => $author_id, // author id
'upload_list' => $upload_list, // list of files to upload
'warning' => null, // String to output as warning
'error' => null, // String to output as error
'redirect' => null, // URL to redirect
'add_post' => true, // Boolean if post will be added
);
用法
<?php
add_filter ( 'asgarosforum_filter_before_post_submit', 'function_name');
?>
示例
<?php
// Reject post if content is too long
add_filter ( 'asgarosforum_filter_before_post_submit', 'reject_long_posts');
function reject_long_posts( $add_post){
// Check lenght of content
if (strlen($add_post['content']) > 1000){
// Set error message
$add_post['error'] = "Your post is too long!!";
// Dump the submitted post
$add_post['add_post'] = false;
}
return $add_post;
}
?>
资源
- asgarosforum_filter_before_edit_post_submit
描述
在提交之前调整已编辑的帖子,或取消提交。
参数
$edit_post
包含帖子所有信息的数组:
$edit_post = array(
'subject' => $this->data_content, // subject of the topic
'content' => $this->data_content, // content of the post
'editor' => $this->asgarosforum->permissions->currentUserID,, // editor id
'upload_list' => $upload_list, // list of files to upload
'warning' => null, // String to output as warning
'error' => null, // String to output as error
'redirect' => null, // URL to redirect
'edit_post' => true, // Boolean if post will be added
);
用法
<?php
add_filter ( 'asgarosforum_filter_before_edit_post_submit', 'function_name');
?>
示例
<?php
// Reject post if content is too long
add_filter ( 'asgarosforum_filter_before_edit_post_submit', 'reject_long_posts');
function reject_long_posts( $edit_post){
// Check lenght of content
if (strlen($edit_post['content']) > 1000){
// Set error message
$edit_post['error'] = "Your post is too long!!";
// Dump the submitted post
$edit_post['edit_post'] = false;
}
return $edit_post;
}
?>
资源
- asgarosforum_filter_before_topic_submit
描述
在提交之前调整主题或取消提交。
参数
$add_topic
包含该主题所有信息的数组:
$add_topic = array(
'forum' => $this->asgarosforum->current_forum, // forum id
'subject' => $this->data_subject, // subject of topic
'content' => $this->data_content, // content of the topic
'author' => $author_id, // author id
'upload_list' => $upload_list, // list of files to upload
'warning' => null, // String to output as warning
'error' => null, // String to output as error
'redirect' => null, // URL to redirect
'add_topic' => true, // Boolean if topic will be added
);
用法
<?php
add_filter ( 'asgarosforum_filter_before_topic_submit', 'function_name');
?>
示例
<?php
// Reject topic if content is too short
add_filter ( 'asgarosforum_filter_before_topic_submit', 'reject_long_posts');
function reject_long_posts( $add_topic){
// Check lenght of content
if (strlen($add_topic['content']) < 50){
// Set error message
$add_topic['error'] = "Your post is too short!!";
// Dump the submitted topic
$add_topic['add_topic'] = false;
}
return $add_topic;
}
?>
资源
- asgarosforum_filter_widget_title_length
- asgarosforum_widget_excerpt_length
- asgarosforum_subscriber_mails_new_post
- asgarosforum_subscriber_mails_new_topic
- asgarosforum_filter_error_message_require_login
- asgarosforum_filter_user_groups_taxonomy_name
- asgarosforum_filter_avatar_size
- asgarosforum_filter_profile_header_image
描述
过滤论坛个人资料头部的背景图片 URL。
参数
$url
背景图片的 URL
$user_id
已显示个人资料的用户 ID。
用法
<?php
add_filter ( 'asgarosforum_filter_profile_header_image', 'function_name', 10, 2);
?>
示例
<?php
// Add filter to customize a user profile header background image
add_filter ( 'asgarosforum_filter_profile_header_image', 'custom_profile_background', 10, 2);
// Remove profile header background if user is admin
function custom_profile_background( $url, $user_id){
// check if user is admin
if ( user_can( $user_id, 'manage_options' )){
$url = false;
}
return $url;
}
?>
资源
- asgarosforum_filter_profile_link
- asgarosforum_filter_history_link
- asgarosforum_filter_show_header
描述
显示或隐藏论坛页眉。
参数
$show_header
用于显示或隐藏标题的布尔值
- true: 显示页眉
- false: 隐藏页眉
用法
<?php
add_filter ( 'asgarosforum_filter_show_header', 'function_name');
?>
示例
<?php
// Add filter to hide forum header for logged out users
add_filter ( 'asgarosforum_filter_show_header', 'hide_header');
// Function to hide header
function hide_header(){
return is_user_logged_in();
}
?>
资源
- asgarosforum_filter_header_menu
描述
过滤 asgaros forum 的页眉菜单。
参数
$menu_entries
包含菜单项数组的数组:
$menu_entries = array(
'name' => array(
'menu_class' => 'HTML Class'
'menu_link_text' => 'Link Text',
'menu_url' => '/url',
'menu_login_status' => '0', // (0 = all, 1 = only logged in, 2 = only logged out)
'menu_new_tab' => true // (true = open in new tab, false = open in same tab
),
);
标准菜单项名称:
| name | description | visibility |
|---|---|---|
| home | Asgaros Forum 首页 | Always |
| profile | 活跃用户的个人资料 | Only logged in |
| memberslist | 所有会员列表 | Always |
| subscription | 管理订阅的页面 | Only logged in |
| activity | 论坛版块所有动态的页面 | Always |
| login | 登录页面 | Only logged out |
| register | 注册页面 | Only logged out |
| logout | 注销当前用户 | Only logged out |
用法
<?php
add_filter ( 'asgarosforum_filter_header_menu', 'function_name');
?>
示例
<?php
// Add filter to customize the forum header menu
add_filter ( 'asgarosforum_filter_header_menu', 'my_custom_menu');
// Function to customize the forum menu
function my_custom_menu( $menu_entries){
// Open memberslist in new tab
$menu_entries['memberslist']['menu_new_tab'] = true;
// Create new menu entry
$menu_entry = array(
'menu_class' => 'impress',
'menu_link_text' => 'Impress',
'menu_url' => '/impress',
'menu_login_status' => '0',
'menu_new_tab' => true
);
// Add Entry at beginning of the menu
array_unshift( $menu_entries, $menu_entry);
return $menu_entries;
}
?>
资源
- asgarosforum_filter_forum_menu
- asgarosforum_filter_topic_menu
- asgarosforum_filter_post_menu
- asgarosforum_filter_members_link
- asgarosforum_filter_automatic_topic_title
- asgarosforum_filter_automatic_topic_content
- asgarosforum_filter_widget_avatar_size
- asgarosforum_filter_get_sticky_topics_order
- asgarosforum_user_replacements
- asgarosforum_seo_trailing_slash
- asgarosforum_reactions
- asgarosforum_widget_recent_posts_custom_content
- asgarosforum_widget_recent_topics_custom_content
- asgarosforum_title_separator
- asgarosforum_filter_profile_row
描述
在 Asgaros Forum 个人资料渲染之前过滤行
参数
$profile_rows
包含个人资料行作为数组的数组:
$profile_rows = array(
'name' => array(
'title' => 'Title of profile row'
'value' => 'Value of profile row',
'type' => '', // optional type of profile row. 'usergroup' or ''
),
);
标准行的名称:
| name | 描述 |
|---|---|
| first_name | 用户的名字/First name of user |
| usergroup | 用户组/Group of user |
| website | 用户网站/Website of user |
| last_seen | 用户最后一次出现/Last seen of user |
| member_since | 用户自加入以来/User is member since |
| bio | 用户简介摘录/Excerpt of users bio |
| signature | 用户签名/Users signature |
$userData
要渲染的个人资料的 WP_User 对象
用法
<?php
add_filter ( 'asgarosforum_filter_profile_row', 'function_name', 10, 2);
?>
示例
<?php
// Add filter to add custom profile row
add_filter ( 'asgarosforum_filter_profile_row', 'my_custom_profile_row', 10, 2);
// Function to customize the forum menu
function my_custom_profile_row( $profile_rows, $userData){
// Create new profile row
$profile_row = array(
'title' => 'Last Name',
'value' => $userData->last_name,
);
// Add row at beginning of the user profile
array_unshift( $profile_rows, $profile_row);
return $profile_rows;
}
?>
资源
- asgarosforum_signature
- asgarosforum_filter_meta_post_type
描述
将元框添加到自定义文章类型
参数
$post_types
带有文章类型的数组
$menu_entries = array('post', 'page');
用法
<?php
add_filter ( 'asgarosforum_filter_meta_post_type', 'function_name');
?>
示例
<?php
add_filter('asgarosforum_filter_meta_post_type', 'add_post_type');
// Add custom post type to the list of post types
function add_post_type ($post_types){
$post_types[] = 'custom_post_type';
return $post_types;
}
?>
资源
- asgarosforum_filter_upload_folder
描述
更改图片上传的文件夹。
参数
$upload_folder
包含当前上传文件夹名称的字符串。
用法
<?php
add_filter ( 'asgarosforum_filter_upload_folder', 'function_name');
?>
示例
<?php
add_filter('asgarosforum_filter_upload_folder', 'change_upload_folder');
// Add custom post type to the list of post types
function change_upload_folder ($upload_folder){
$upload_folder = 'new_upload_folder';
return $upload_folder;
}
?>
