Advertisement
sgaffney

add user

Dec 7th, 2011
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.85 KB | None | 0 0
  1. /**
  2.  * Adds the default roles for all sites to a user, specified by $user_id
  3.  */
  4. function msum_add_roles( $user_id ){
  5.  
  6.     global $woocommerce;
  7.  
  8.     foreach( msum_get_blog_list( 0, 'all' ) as $key => $blog ) {
  9.  
  10.         if( is_user_member_of_blog( $user_id, $blog[ 'blog_id' ] ) )
  11.             continue;
  12.  
  13.         switch_to_blog( $blog[ 'blog_id' ] );
  14.  
  15.         $role = get_option( 'msum_default_user_role', 'none' ); // if no default set, use 'none'
  16.  
  17.         if( $role != 'none' )
  18.             add_user_to_blog( $blog[ 'blog_id' ], $user_id, $role );
  19.  
  20.         restore_current_blog();
  21.     }
  22.     update_user_meta( $user_id, 'msum_has_caps', 'true' );
  23. }
  24. //add_action( 'wpmu_activate_user', 'msum_add_roles', 10, 1 );
  25. //add_action( 'wpmu_new_user', 'msum_add_roles', 10, 1 );
  26. //add_action( 'user_register', 'msum_add_roles', 10, 1 );
  27. add_action( 'woocommerce_order_status_completed', 'msum_add_roles', 10, 1);
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement