我正在寻找实现以下目标的方法:
一群用户的学生
他们登录网站
每个学生都可以看到“自定义仪表板小部件”
每个小部件将携带管理员为登录学生编写的个人消息。例如A]课程总天数B]总出勤率C]已付&;到期费用。
是否可以使用WP,或者我们是否应该寻找其他CMS来实现这些目标?
我正在寻找实现以下目标的方法:
一群用户的学生
他们登录网站
每个学生都可以看到“自定义仪表板小部件”
每个小部件将携带管理员为登录学生编写的个人消息。例如A]课程总天数B]总出勤率C]已付&;到期费用。
是否可以使用WP,或者我们是否应该寻找其他CMS来实现这些目标?
可以使用用户配置文件中的自定义元字段(仅对管理员可见)解决此问题,然后制作包含此元的单个仪表板小部件(仅在满足特定条件时可见)。
可以通过以下方式向用户配置文件页面添加字段:
遵循Frank Bültge的教程:Add WordPress Dashboard Widgets
通过插件previous Answer 使用了另一个插件,但注释线程解释了更改
由于密码和维护良好,Advanced Custom Fields 非常方便。
/wp-admin/user-edit.php?user_id=7
/**
* Add Dashboard Widget
*/
add_action(\'wp_dashboard_setup\', \'wpse_51591_wp_dashboard_setup\');
/**
* Only builds the Widget if the display message checkbox is enabled in the user editing screen
*/
function wpse_51591_wp_dashboard_setup()
{
global $current_user;
get_currentuserinfo();
$show_msg = get_field( \'user_message_enable\', \'user_\' . $current_user->ID );
$widget_title = \'Personal Messages to \' . $current_user->data->display_name;
if( $show_msg )
wp_add_dashboard_widget( \'wpse_user_personal_message\', $widget_title, \'wpse_51591_wp_dashboard_per_user\' );
}
/**
* Content of Dashboard Widget
* Shows the content of each user\'s custom message
*/
function wpse_51591_wp_dashboard_per_user()
{
global $current_user;
get_currentuserinfo();
$the_msg = get_field( \'user_message_text\', \'user_\' . $current_user->ID );
echo $the_msg;
}
Results in:Bonus code
add_action( \'admin_head-user-edit.php\', \'wpse_51591_acf_profile\' );
add_action( \'admin_head-user-new.php\', \'wpse_51591_acf_profile\' );
function wpse_51591_acf_profile()
{
?>
<script type="text/javascript">
jQuery(document).ready( function($)
{
/* Wait 1.4s for ACF to be ready */
setTimeout(function() {
// find our checkbox
var the_check = $(\'#acf-user_message_enable\').find(\'input:last\');
// default state
if( $(the_check).is(\':checked\') )
$(\'#acf-user_message_text\').fadeIn();
else
$(\'#acf-user_message_text\').fadeOut();
// live changes
$(the_check).change(function ()
{
if( $(this).is(\':checked\') )
$(\'#acf-user_message_text\').fadeIn();
else
$(\'#acf-user_message_text\').fadeOut();
});
}, 1400);
});
</script>
<?php
}
我想在仪表板提要上添加一个订单数字,如下图所示:http://i.stack.imgur.com/kK0GJ.png我编辑了默认的小部件。php-函数wp\\u widget\\u rss\\u output(),但仍然没有显示任何更改。PS:我正在使用WPMUDEV仪表板提要插件。这个插件更改了widget\\u选项,这样我就可以显示自己的RSS提要,而不是默认的Wordpress提要!