Cannot select signup_meta upon multisite user activation
I am having trouble selecting signup meta, it always returns empty array.
My code is:
add_action( 'wpmu_activate_user', 'promote_to_admin', 99 );
function promote_to_admin( $user_id, $password, $meta ) {
global $wpdb;
$user = get_userdata( $user_id );
$email = $user-user_email;
var_dump( $email );
$signup_meta = $wpdb-get_results( "SELECT meta FROM wp_signups WHERE user_email = $email" );
if ( $signup_meta['new_role'] == 'administrator' ) {
$user-set_role( 'administrator' );
}
}
$signup_meta
is returned as an empty array. However, when I check the database, the signup_meta
array contains values.
I also tried dumping $user
and $email
- everything is fine, $user
object is populated with data and $email
is correct.
Anybody know what can be the issue here and how can I retrieve the signup meta?
Scenario is when a new user is added by Admin from Dashboard. My goal is to parse the role that is assigned when new user is created by admin.
It's a bug fixing attempt, since the plugin that I am using to manage custom and default roles (WPFront User Role Editor), overrides the Administrator role assigned to a new user from the Dashboard. So, when a new user is activated I want to check if he was initially assigned Administrator role and update the default role assigned by the plugin.
Topic wp-signup multisite-user-management multisite Wordpress
Category Web