Comment retarder la capacité de publier des articles?
1 réponses
- votes
-
- 2012-03-29
Iln'y aurapas depluginpour ça,alorsj'en ai écrit un. Vouspouvez l'utiliser commeplugin ou (mieux) commepluginmu (placez-le dans votre dossier
~/wp-content/mu-plugins
).Mu-Plugin: retarder lapossibilité de "publier unpost"en supprimant la MetaBox
Pour uneexplication détaillée de ce qui sepasseet pourquoi cela seproduit,veuillez vous référer aux commentairesen ligne:
<?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 );
D'autresmises àjour de ceplugin sont disponibles dans this Gist .
Peut également disponible dans le référentiel deplugins WPSE .
There won't be a plugin for that, so I wrote one. You can use it as plugin or (better) a mu-plugin (place it in your
~/wp-content/mu-plugins
folder).Mu-Plugin: delay the possibility to "publish a post" by removing the MetaBox
For a detailed explanation of what happens and why it happens, please refer to the inline comments:
<?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 );
Further updates for this plugin can be found in this Gist.
-
Bien,maispouvez-vousexpliquer comment celafonctionne?Cela résout leproblèmemaisne répondpas à la questionNice, but can you explain how this works? It solves the problem but it doesn't answer the question
- 0
- 2014-12-04
- Tom J Nowell
-
@TomJNowell Voir les commentaires de codeen ligne.@TomJNowell See inline code comments.
- 0
- 2014-12-04
- kaiser
J'utilisebuddypresset tous lesnouveauxmembres ont le rôle d'auteur.Le site ressembleplus à unforum avec un seul sujet.Jene suispasinquiet des commentaires,juste desposts .
Récemment,j'ai reçu untas de spam d'utilisateurs.Commentpuis-jeempêcher les utilisateurs depublier desmessagespendant aumoins une semaine?