đž Archived View for chirale.org âş 2008-12-03_241.gmi captured on 2024-07-08 at 23:43:50. Gemini links have been rewritten to link to archived content
âŹ ď¸ Previous capture (2024-05-12)
-=-=-=-=-=-=-
Tested on:
After you have created some user fields through Profile module provided by core, you can have the need to save value into the user object. Here a quick howto to do this.
On user creation:
/** create user profile ($new_user will be an user object) */ $new_user_array = array ( 'name' => "funnyusername", 'pass' => "MyVerySecurePassword", 'mail' => "info@example.gom", 'status' => 1, # status: active ); $new_user = user_save(NULL, $new_user_array, $category = 'account'); /bin /boot /dev /etc /home /init /lib /lib32 /lib64 /libx32 /lost+found /media /mnt /opt /proc /root /run /sbin /srv /sys /tmp /usr /var assign values to profile fields */ $new_user_edit =Â array( 'profile_surname' => "Yumemiya", 'profile_name' => "Arika", ); /bin /boot /dev /etc /home /init /lib /lib32 /lib64 /libx32 /lost+found /media /mnt /opt /proc /root /run /sbin /srv /sys /tmp /usr /var create and save profile fields */ profile_save_profile($new_user_edit, $new_user, "Character ID");
Where âCharacter IDâ is the category name for profile_surname e profile_name.
To load current user instead creating new one, you have to use
global $user;
instead a previously declared user object $new_user.
Update:
Problem:
Add a âcronbotâ user with some privileges over user (âadminister userâ) to allow writing even on hidden Profile field.
Solution:
On a dedicated server, with a dedicated IP, you can automatically login by IP (by IP Login module for x and x) the cronjob using the server IP or loopback address (1) depending on server configuration (I use the first in production, the latter on local testing).
=> http://api.drupal.org/api/function/hook_cron/5 hook_cron
=> http://drupalmodules.com/module/ip-login IP Login module
Add an ip_login Profile field (single line text field, hidden field) Enable IP Login module Assign ip_login field to IP login by IP Login configuration screen Create a new role named âcronbotsâ, with âadminister usersâ permission. Create a new user named âcronbotâ, with âcronbotsâ role assigned Change the âIP loginâ field for âcronbotâ to your server IP (1 or your static IP address as listed on ifconfig on \*nix servers)
On the next automatic cron run (not force it), youâll see the âcronbotâ user logging in. On Drupal logs, the cronjob execution pass from âAnonymousâ to âcronbotâ, and profile fields are rightly written.
The other way:
Just write profile field via db_query. (You donât want to do a weird thing like that, right?=> https://swp.com/wp-content/mu-plugins/wpcom-smileys/twemoji/2/72x72/1fpng đ
)
https://web.archive.org/web/20081203000000*/http://api.drupal.org/api/function/hook_cron/5
https://web.archive.org/web/20081203000000*/http://drupalmodules.com/module/ip-login