Home Forums Plugin Support WP User Frontend Pro Change post status if usergroup = admin

This topic is: resolved

This topic contains 5 replies, has 2 voices, and was last updated by  Sparhamster 6 years, 1 month ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #2395

    Sparhamster
    Participant
    Post count: 22

    Hi,

    hopefully my last problem / question ๐Ÿ˜‰

    if a user post an article from a form which get the status “pending”, the post will also be “pending” if the user edit this article. thats good ๐Ÿ˜‰ but its not good, that the status will switch from “published” to “pending” if a admin will edit the article over the wpuf edit form.

    How can i change the post status in a filter? if the usergroup = “admin” the post status has to set from “pending” to “published”.

    i work with that function in the functions.php

    function get_user_role() {
    global $current_user;

    $user_roles = $current_user->roles;
    $user_role = array_shift($user_roles);

    return $user_role;
    }

    so i get the user_role with get_user_role() and the output is for example “administrator” ๐Ÿ˜‰

    thx!

    #2397

    Tareq Hasan
    Keymaster
    Post count: 2831

    Pasting code directly from a project, might help ๐Ÿ˜‰

    [php]
    function dlp_wpuf_editor_post_status( $postarr ) {

    if ( dlp_is_admin() || dlp_is_editor() ) {
    $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]

    #2398

    Sparhamster
    Participant
    Post count: 22
    This reply has been marked as private.
    #2399

    Sparhamster
    Participant
    Post count: 22

    hm..it wont work… the submit / edit button is loading and loading … ๐Ÿ™

    #2400

    Tareq Hasan
    Keymaster
    Post count: 2831

    My example is also got two different user roles, perhaps some PHP errors came up in your case. Fix your code.

    #2401

    Sparhamster
    Participant
    Post count: 22
    This reply has been marked as private.
Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘Change post status if usergroup = admin’ is closed to new replies.