How to make WordPress that when a user writes an article and if there are certain words or links there, then you must first pass moderation?
MB is there any plugin, or filters?
How to make WordPress that when a user writes an article and if there are certain words or links there, then you must first pass moderation?
MB is there any plugin, or filters?
You need to use the WordPress save_post filter, which works when you save a post.
add_action( 'save_post', 'save_post_action' ); function save_post_action( $post_id ) { if ( wp_is_post_revision( $post_id ) ) { return; } $post = get_post( $post_id ); if ( 'pending' === $post->post_status ) { return; } $content = $post->post_content; if ( ! check_content( $content ) ) { // Удаляем хук, чтобы не было зацикливания remove_action( 'save_post', 'save_post_action' ); // Обновляем запись. В это время срабатывает событие save_post wp_update_post( array( 'ID' => $post_id, 'post_status' => 'pending', ) ); // Ставим хук обратно add_action( 'save_post', 'save_post_action' ); } } The example assumes that you have a check_content () function that returns true or false depending on the content of the post (the words or links in the question).
Source: https://ru.stackoverflow.com/questions/833170/
All Articles