我使用buddypress,所有新成员都具有作者角色。该网站更像是一个只有一个主题的论坛。我不担心评论,just posts.
最近我收到了一堆来自用户的垃圾邮件。我如何防止用户至少一周内实际发帖?
我使用buddypress,所有新成员都具有作者角色。该网站更像是一个只有一个主题的论坛。我不担心评论,just posts.
最近我收到了一堆来自用户的垃圾邮件。我如何防止用户至少一周内实际发帖?
没有插件,所以我写了一个。您可以将其用作插件或(更好)mu插件(将其放置在~/wp-content/mu-plugins
文件夹)。
<?php
/**
* Plugin Name: Delay post publishing
* Plugin URI: http://unserkaiser.com
* Description: Only allows publishing a post if the user registered one week ago.
* Version: 0.1
* Author: Franz Josef Kaiser
* Author URI: http://unserkaiser.com
*/
// Only run this for new "post"-post_type admin UI screens
if ( ! is_admin() AND \'post-new.php\' !== $GLOBALS[\'typenow\'] ) return;
function remove_publish_metabox_until_date()
{
// Retrieve the current users\' data as object
$curr_user = get_user_by( \'id\', get_current_user_id() );
// Get the time/date (and format) of the time
// the user registered as UNIX timestamp - needed for comparison
$reg_date = abs( strtotime( $curr_user->user_registered ) );
$curr_date = abs( strtotime( current_time( \'mysql\' ) ) );
// Human readable difference: This calculates the time since the user registered
$diff = human_time_diff( $reg_date, $curr_date );
$diff_array = explode( \' \', $diff );
// Remove if we\'re on the 1st day (diff result is mins/hours)
// This removes the MetaBox
if (
strstr( $diff_array[1], \'mins\' )
OR strstr( $diff_array[1], \'hours\' )
)
return remove_meta_box( \'submitdiv\', null, \'side\' );
// Remove if we\'re below or equal to 7 days (1 week)
// This removes the MetaBox
if ( 7 >= $diff_array[0] )
return remove_meta_box( \'submitdiv\', null, \'side\' );
}
add_action( \'add_meta_boxes\', \'remove_publish_metabox_until_date\', 20 );
有关此插件的更多更新,请访问this Gist.是否有方法跟踪登录的用户活动?我想看看谁每天都登录到这个网站,也许还能看到特定的人的登录历史。目前我不知道哪些注册用户正在访问我的网站。这是一个私人家庭网站~20 members 我只是想知道谁在使用它,谁没有使用它。