Send private message

You must be logged in to send a private message.

Friends

No friends yet.

Group membership

Activity

  • Mig added a new discussion topic Add metadata to all users in the group Performance and Scalability
    Hi,   I want to add a metadata field to all users in my page. I want it for all registered users and for the new registers too.   I tried to add a plugin for the new...
    • For new users:

      <?php
      
      elgg_register_event_handler('init', 'system', 'registro_nuevo_init');
      
      function registro_nuevo_init() {
          elgg_register_event_handler('create', 'user', 'inicializa_datos');
      }
      
      function inicializa_datos($event, $type, $user) {
          $user->puntuacion = '0';
      }

      For existing users you could create a script you directly call/execute once (e.g. named it user_update.php and save it in the Elgg install root folder and then call it in your browser with site.url/user_update.php). The following is for Elgg 2.x versions:

      <?php
      
      require_once __DIR__ . '/vendor/autoload.php';
      \Elgg\Application::start();
      
      $ia = elgg_set_ignore_access(true);
      $access_status = access_get_show_hidden_status();
      access_show_hidden_entities(true);
      
      $entities = new ElggBatch('elgg_get_entities', array(
          'type' => 'user',
          'limit' => false,
      ));
      
      foreach ($users as $user) {
          $user->puntuacion = '0';
      }
      
      access_show_hidden_entities($access_status);
      elgg_set_ignore_access($ia);