Created
March 29, 2012 14:52
-
-
Save franz-josef-kaiser/2238167 to your computer and use it in GitHub Desktop.
Delay the ability to publish posts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 | |
*/ | |
// Not a WordPress context? Stop. Why? Ask @toscho | |
! defined( 'ABSPATH' ) AND exit; | |
// Only run this for new "post"-post_type admin UI screens | |
if ( ! is_admin() AND 'post-new.php' !== $GLOBALS['typenow'] ) return; | |
function debug_user() | |
{ | |
// User data as object | |
$curr_user = get_user_by( 'id', get_current_user_id() ); | |
// get time/date and format as UNIX timestamp | |
$reg_date = abs( strtotime( $curr_user->user_registered ) ); | |
$curr_date = abs( strtotime( current_time( 'mysql' ) ) ); | |
// Human readable difference | |
$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) | |
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) | |
if ( 7 >= $diff_array[0] ) | |
return remove_meta_box( 'submitdiv', null, 'side' ); | |
} | |
add_action( 'add_meta_boxes', 'debug_user', 20 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment