Advertisement
arie_cristianD

post_published_from_front_end

Aug 21st, 2023 (edited)
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.41 KB | None | 0 0
  1. add_filter( 'jnews_frontend_submit_create_post', 'jnews_frontend_post_status_change' );
  2. function jnews_frontend_post_status_change( $args ) {
  3.     if ( is_user_logged_in() ) {
  4.         $roles = array( 'author', 'editor', 'administrator' );
  5.         $user  = wp_get_current_user();
  6.         foreach ( $roles as $role ) {
  7.             if ( in_array( $role, $user->roles ) ) {
  8.                 $args['post_status'] = 'publish';
  9.                 return $args;
  10.             }
  11.         }
  12.     }
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement