Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Tareq Hasan

    (@tareq1988)

    Yes you can, in that case you would need some code to do so. There’s example here, take a look at Disabling posting capability section

    Based on your link, I modified the code to set time frame as below, but it is not working. Could you please look into it? Thanks in advance

    /**
     * Check if the current user can post
     *
     * @return bool
     */
    function wpufe_can_post() {
    	global $post_type;
        global $wpdb;
    	global $userdata;
        $user = wp_get_current_user();
    
    	if( $post_type === 'post' ) {
    		$today = date( 'Y-m-d 00:00:00', ( gmmktime() ));
    		$news_count = $wpdb->get_var( "SELECT count(*) FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' AND post_author = $userdata->ID AND post_modified > '$today'" );
    		if( $news_count >= 1 ) {
    		return false;
    		}
    		return true;
    	}
    
    }
    
    /**
     * Show the message if can't post
     *
     * @param string info message
     * @return string info message
     */
    function wpufe_show_message( $info ) {
        if( !wpufe_can_post() ) {
            $info = 'Sorry, you have exceeded the limit of post per day';
        }
    
        return $info;
    }
    add_filter( 'wpuf_addpost_notice', 'wpufe_show_message' );
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Can you limit the number of posts?’ is closed to new replies.