已创建论坛回复
-
作者帖子
-
找到了,新建一个页面使用短代码[bbp-topic-form]就可以。
还是感谢!
上边的代码,有个BUG,在个人档案中心->创建的回复中,都会显示“楼主”,因为你是回复别人的,肯定不可能是楼主,所以还需要修改一下代码。
修改后的代码如下:
//添加楼主和非楼主角色 function bbp_post_starter( $args = '' ) { $topic_author = bbp_get_topic_author_id(); $reply_author = bbp_get_reply_author_id( $reply_id ); if ( bbp_is_single_user_replies() ) { } elseif ( $reply_author === $topic_author ) { ?> <span class="post-starter-bq">楼主</span> <?php } } add_filter('bbp_theme_after_reply_author_details', 'bbp_post_starter');
我自己解决这个问题了,灵感来自bbpress-private-replies这款插件。
把下面代码添加到functions.php文件就可以在回复帖子作者头像下边显示“楼主”了,同时,楼主在该主题下回复的帖子,也会楼主两个字。
function bbp_post_starter( $args = '' ) { $topic_author = bbp_get_topic_author_id(); $reply_author = bbp_get_reply_author_id( $reply_id ); if ( $reply_author === $topic_author ) { ?> <span class="xxx">楼主</span> <!--?php <br ?--> } } add_filter('bbp_theme_after_reply_author_details', 'bbp_post_starter');
如果需要修改样式,可以把上边函数中的xxx换成你的样式。
看看我的样式吧:
好的,多谢,好找了好久了,找不到相关函数。
https://bbpress.org/forums/topic/user-profile-url-uses-the-username-can-that-be-changed/
这个链接里面给出的函数很有用。
他给出的函数本身是用来把username改为displayname,意外的是,还有另外一个收获,就是不用@username了,只需要@displayname,对方就会收到邮件提醒了。不过,有个坏处,就是displayname可以有重名,重名的用户,都会收到邮件。
我稍微把作者的函数修改了一下,修改为显示用户的ID号,这样,就可以通过@用户ID来通知对方有回复了。
这是修改后的代码:
add_action( 'init', 'nicenames_to_display_name' ); function nicenames_to_display_name() { foreach ( get_users() as $user ) { if ( $user->data->user_status == 0 && $user->data->user_nicename != $user->data->display_name ) { $user_ids[] = $user->ID; } } foreach( $user_ids as $uid ) { $info = get_userdata( $uid ); $display_name = $info->data->display_name; if ($display_name) { $args = array( 'ID' => $uid, 'user_nicename' => strtolower(str_replace(" ", "_", $uid)) ); wp_update_user( $args ); } } }
改成数字ID的那个帖子,我试过上面给的代码了,管用,他的问题和我的一样,不想暴露用户的email。
bbPress Direct Quotes 这个插件试了一下,不起作用,估计是年久失修了。
在论坛中,直接点击某个楼回复,如果不开启嵌套回复,根本看不出来是回复的谁。
但是如果开启嵌套回复的话,在手机上的效果很差,最不能容忍的是,嵌套回复不分页。
所以还是改回了不嵌套。
很纠结。
我现在通过这个插件
bbPress Mentions Email Notifications
实现了@用户名后给这个用户发送邮件的功能。
这个插件试过了,还是不起作用。
多谢!
这个应该不是你们修改的问题,我试了下没有经过任何修改的bbpress,那个回复选项也不起作用,就是不给发邮件。
-
作者帖子