Created
February 3, 2022 15:39
-
-
Save mklasen/b0ff4021781947c94e21f4c5609430f3 to your computer and use it in GitHub Desktop.
Uncanny Import Users: Automatically give the user the default role when the user exists in the network, but not on the site.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Sample { | |
public function __construct() { | |
$this->hooks(); | |
} | |
public function hooks() { | |
add_action( 'uo_after_user_row_imported', array( $this, 'add_user_to_multisite' ), 99, 4 ); | |
} | |
public function add_user_to_multisite( $user_id, $current_row, $csv_header, $key_location ) { | |
$user = new \WP_User( $user_id ); | |
if ( empty( $user->roles ) ) { | |
$user->add_role( get_option( 'default_role' ) ); | |
} | |
} | |
} | |
new Class(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment