marinel (April 13th, 2012)
// limit number of posts per user
// provided by cleverness.org
if ( !current_user_can('manage_options') ) {
$default = 1; // default number of posts
$count_posts = 0;
global $wpdb;
$poststable = $wpdb->prefix.'posts';
$postlimit = get_user_meta($current_user->id, 'postlimit', true);
if ( $postlimit == '' ) $postlimit = $default;
$query = "SELECT COUNT(*) FROM $poststable WHERE post_author = '$current_user->id' AND (post_status = 'pending' OR post_status = 'draft' OR post_status = 'publish' ) ";
$count_posts = $wpdb->get_var($query);
if ($count_posts >= $postlimit) {
if ( $_SERVER['REQUEST_URI'] == '/wp-admin/post-new.php' )
Header("Location: index.php");//redirects to dashboard
if ( is_admin() ){
$stylesheet = get_stylesheet_directory_uri() . '/css/limitposts.css';
wp_register_style('limitpost_admin_css', $stylesheet, false, '1', 'screen');
wp_enqueue_style('limitpost_admin_css');
}
}
}
// add post limit option to profile
add_filter('user_contactmethods','hide_profile_fields',10,1);
function hide_profile_fields( $contactmethods ) {
if( current_user_can( 'manage_options' ) )
$contactmethods['postlimit'] = 'Post Limit';
return $contactmethods;
}
#menu-posts .wp-first-item + li {
display: none;
}
if ( $_SERVER['REQUEST_URI'] == '/wp-admin/post-new.php' )
if ( $_SERVER['REQUEST_URI'] == '/wp-admin/post-new.php?post_type=customposttype' )
#menu-posts-customposttype .wp-first-item + li {
display: none;
}
marinel (April 13th, 2012)
buddhan (February 20th, 2012)
There are currently 1 users browsing this thread. (0 members and 1 guests)