vapvarun

BuddyPress User Blog - Restrict for subscribers

Jul 8th, 2016
371
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. add_action( 'bp_setup_nav', 'bboss_maybe_sap_setup_nav', 90 );
  3. function bboss_maybe_sap_setup_nav(){
  4.     if( !class_exists( 'BuddyBoss_SAP_Blog' ) )
  5.         return;
  6.    
  7.     $instance = BuddyBoss_SAP_Blog::instance();
  8.     if( !user_can( bp_displayed_user_id(), 'edit_posts' ) ){//not an author
  9.         remove_action( 'bp_setup_nav', array( $instance, 'sap_setup_nav' ), 100 );
  10.     }
  11. }
  12.  
  13. add_action( 'bp_setup_admin_bar', 'bboss_maybe_sap_setup_admin_bar', 70 );
  14. function bboss_maybe_sap_setup_admin_bar(){
  15.     if( !class_exists( 'BuddyBoss_SAP_Blog' ) || !is_user_logged_in() )
  16.         return;
  17.    
  18.     $instance = BuddyBoss_SAP_Blog::instance();
  19.     if( !user_can( bp_loggedin_user_id(), 'edit_posts' ) ){//not an author
  20.         remove_action( 'bp_setup_admin_bar', array( $instance, 'sap_setup_admin_bar' ), 80 );
  21.     }
  22. }
Add Comment
Please, Sign In to add comment