I am trying to add meta_key and meta_value for the all already registered user in my database via phpmyadmin.

I want: meta_key = is_activated and meta_value = 1 enter image description here


closed as unclear what you're asking by Mayeenul Islam, fuxia Mar 9 '17 at 10:27

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.


Add this code in functions.php. visit your site you, it will automatic add/update all user meta value. After executing this code just comment out or remove this code.

$args = array(
  'fields'       => 'all',
$blogusers = get_users( $args);
foreach($blogusers as $key => $user){
  update_user_meta( $user->ID, 'is_activated', 1 );

OR you can also do this using $wpdb

global $wpdb;
$users = $wpdb->get_results( "SELECT ID FROM $wpdb->users" );
if( $users ) {
  foreach ( $users as $user ) {
    update_user_meta( $user->ID, 'is_activated', 1 );

check PHPMyAdmin you will find every user meta_key=is_activated is set to 1.

  • Many Thanks. I used your first code.It works fine. – Nitish Paswan Mar 8 '17 at 10:30

Not the answer you're looking for? Browse other questions tagged or ask your own question.