limit – dmin-notice after limiting a custom post type


I did a limitation for a custom post type “vereine”. It works, but the admin notice is that the custom post is published (and not draft). How can I add a message? Here is the code for the limiting

function post_published_limit() {
    $max_posts = 1; // anzahl der maximalen Vereinseintragungen
    $author = $post->vereinsmanager; // nur fuer vereinsmanager limitierung

    $count = count_user_posts( $author, 'vereine'); 

    if ( $count > $max_posts ) {
        // wenn mehr als 1, dann auf Entwurf setzen und Notiz für vereinsmanager ausgeben
        $post = array('post_status' => 'draft');
        wp_update_post( $post );
add_action( 'publish_vereine', 'post_published_limit' );

thank you for your help, greetings

Steph 2 years 2021-04-23T05:55:45-05:00 0 Answers 0 views 0

Leave an answer