Home Forums Plugin Support WP User Frontend Pro Post status for roles

This topic is: resolved

This topic contains 2 replies, has 2 voices, and was last updated by  Stepan 5 years, 2 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #16980

    Stepan
    Member
    Post count: 4

    Hi, small question – I'd like to have a possibility to allow users with certain roles to publish their posts without “pending” status.
    I mean, for example, user with role “Subscriber” is able to create a new post, but this post will have “pending” status, and then somebody from administration must approve it.
    And user with role “Author” also is able to create post, but his post must have status “published” at once.
    Is this possible?

    #16983

    Tareq Hasan
    Keymaster
    Post count: 2831

    Yes, possible. Try this:

    [php]
    function dlp_wpuf_editor_post_status( $postarr ) {

    $user = wp_get_current_user();
    $role = reset( $user->roles );

    if ( $role == ‘author' ) {
    $postarr[‘post_status'] = ‘publish';
    }

    return $postarr;
    }

    add_filter( ‘wpuf_add_post_args', ‘dlp_wpuf_editor_post_status' );
    add_filter( ‘wpuf_update_post_args', ‘dlp_wpuf_editor_post_status' );
    [/php]

    Insert this snippet to your themes functions.php

    #16988

    Stepan
    Member
    Post count: 4

    It works! ๐Ÿ™‚ thanks!

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Post status for roles’ is closed to new replies.