2

Is there is a specific ACT command in Expression Engine 3 I can run from a template to create members?

I can probably do this by saving directly to the database and while the password is not a problem since I can hash it I have no idea what Expression Engine is using for the salt and other hashes in the ee_members tables since there is more than one. Is there a clean way to create members programatically?

1

ExpressionEngine has most program friendly structure for this.

You can just write 2 db insert commands to save members programatically. Where 1 table would be exp_members and other one is exp_member_data.

For password, You can encrypt it with md5 algorithm and leave salt and unique key fields blank. When user will login for the first time, password will be encrypted with salt and data will be save in table. (EE handles that.)

I would use this 2 queries to save members:

INSERT INTO `exp_members` (`group_id`, `username`, `screen_name`, `password`, `email`, `ip_address`, `join_date`) VALUES ('5', 'test_user', 'test user', MD5('test_user'), 'test_user@gmail.com', '192.168.1.1', '1534230407');

You will then need to fire a select query that will give you member_id of data you just inserted. You can use username, email etc. to filter the result to get member_id. Once you get member_id, you can fire another query in exp_member_data.

INSERT INTO `exp_member_data` (`member_id`) VALUES ('$MY_MEMBER_ID');

Note: Create member programatically live above will not validate data with EE validation library. If you want to have this functionality for backend it is fine. But, Use any member plugin for frontend member registration.

| improve this answer | |
  • Thank you but the ee_members tables has additional fields called "salt" and "crypt_key" as well. Its not enough to just fill the hashed password and the unique ID and the rest of the fields while leaving those blank. The closest I found which I used for EE 2 but does not work on EE 3 anymore is this: github.com/intoeetive/auto_register If you take a look, its using EE queries to create the user with a random password then changes the password and assigns the user a unique ID. This is not for any user front end, security is not a concern. – nibb11 Aug 14 '18 at 7:48
  • 1
    THANK YOU! While I was already doing the first query, I had no idea you need to also fire the exp_member_data table. The missing data on ee_members is now filled automatically after the first log in. It works great! – nibb11 Aug 14 '18 at 7:58
  • Glad it works for you. As I mentioned above, You not need to worry about salt and crypt_key. It will created automatically once you logged_in first time with that user. It will also encrypt your MD5 password into hashed string (encrypt with salt and crypt key) – Mufi - Amici Infotech Aug 14 '18 at 10:57
  • Why is EE using md5 which is highly insecure for hashing? Should this not be bcrypt or at least sha? – nibb11 Aug 14 '18 at 20:01
  • ha ha.. Encryption depends on length of the string.. prntscr.com/kirlrv . Moreover, it not lends only on this encryption. It will encrypt it again with salt and crypt key when you log in for the first time. – Mufi - Amici Infotech Aug 15 '18 at 5:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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