Advertisement
mrapino

Possible solution for custom profiles for user roles

Aug 18th, 2014
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.83 KB | None | 0 0
  1. add_action( 'xprofile_filter_profile_group_tabs', 'mar_define_profile_by_role' );
  2.    
  3.     function mar_define_profile_by_role( $group_names ) {
  4.        
  5.         global $current_user;
  6.         $user_roles = $current_user->roles;
  7.         $user_role = array_shift($user_roles);
  8.        
  9.         if ( is_user_logged_in() && bp_is_profile_edit() ) {
  10.        
  11.             if( $user_role == "writer" ) {
  12.                 for ($x=0; $x<=sizeof($group_names); $x++) {
  13.                      if ( $x != 2 ) echo $group_names[$x]; //3 is the order number (from 0) of the tab that I need to hide in the profile edit page. This is not the group ID.
  14.                 }
  15.             } elseif( $user_role == "publisher" ) {
  16.                 for ($x=0; $x<=sizeof($group_names); $x++) {
  17.                      if ( $x != 1 ) echo $group_names[$x]; //3 is the order number (from 0) of the tab that I need to hide in the profile edit page. This is not the group ID.
  18.                 }
  19.             }
  20.         }
  21.        
  22.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement