-1

I want to INSERT a row in a custom table when Admin will create an user from admin panel.

I have written a function for this but it is not working.

<?php

add_action( 'user_register', 'myplugin_registration_save', 10, 1 );

function myplugin_registration_save( $user_id ) {

    global $wpdb;
    $user_info = get_userdata($user_id);
    $admin_id = $user_info->ID;
    $user_name =  $user_info->user_login;
    $role = implode(', ', $user_info->roles);

    $table = 'my_users';
    $data = array(
        'admin_id'=>$admin_id,
        'role'=>$role,
        'username'=>$user_name
    );

    $wpdb->insert($table, $data);
}

?>

How can I resolve this?

Wahidul Alam
  • 1,216
  • 4
  • 26
  • 56

1 Answers1

0

You can debug your data using wp_die() and can debug data is getting or not

Wahidul Alam
  • 1,216
  • 4
  • 26
  • 56