Advertisement
fauzanjeg

restrict post submit by roles

Jan 31st, 2021
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.66 KB | None | 0 0
  1. /* restrict post submit by roles */
  2. function jnews_post_submit_access() {
  3.     $roles = array( 'administrator', 'editor', 'author', 'contributor' ); /* list roles */
  4.     $user_role = (array) wp_get_current_user()->roles; /* Get user role */
  5.  
  6.     if ( in_array($user_role[0], $roles) ) {
  7.         $button =
  8.             '<div class="frontend-submit-button">
  9.                 <a class="button" href="' . home_url( '/editor' ) . '"><i class="fa fa-file-text-o"></i> ' . esc_html__( 'Submit Post', 'jnews-frontend-submit' ) . '</a>
  10.             </div>';
  11.  
  12.         echo jnews_sanitize_output( $button );
  13.     }
  14. }
  15.  
  16. remove_all_actions('jnews_after_account_nav' );
  17. add_action( 'jnews_after_account_nav', 'jnews_post_submit_access' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement