简体   繁体   中英

moodle version 3.1 integration with amember

In our system we want to integrate moodle plugin(version 3.1) with amember.We have some users in moodle with passwords in encrypted format and we want to import those users to amember without changing users passwords using api.

Can anyone please suggest a way how can we handle this?

I am using following code to create users in amember.it successfully create users in amember but when i try to login it denied.

$url = 'http://YOURDOMAIN.COM/amember/api/users';

$fields = array(
'_key' => 'SECRETKEY',
'_format' => 'xml',
'login' => 'USERNAME',
'pass' => 'PASSWORD',
'email' => 'EMAIL',
'name_f' => 'FIRST NAME',
'name_l' => 'LAST NAME',
);
 //open connection
$ch = curl_init();

//set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields));
 curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-type: application/x-  www-form-urlencoded"));

//execute post
$result = curl_exec($ch);

//close connection
curl_close($ch);

Thanks in advance.

Since the passwords in moodle are encrypted, you won't be able to decrypt the passwords. As I read your code, amember api will require a plain password when creating a user.

The only workaround I see would result in having an own authentification plugin in moodle. This plugin will be called once an existing moodle users tries to login. You can then use the user_login method, to verify the password against moodle database. Furthermore in this stage you have the plaintext password, so you can create a new amember user, once login is successful

You do not need to use API in order to import users.

aMember has admin tool that allow you to import users from CSV files. This tool allow you to import user with encrypted/hashed passwords.

aMember CP -> Users -> Import Users

You can export user from your moodle database to CSV file.

You need to enable moodle integration plugin within aMember before do such import.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM