Moodle amember integration - Parent Mental Trainer · 2016. 2. 19. · Moodle – amember...
Transcript of Moodle amember integration - Parent Mental Trainer · 2016. 2. 19. · Moodle – amember...
Moodle – amember integration
Step 1: Installation of Moodle and amember
Install moodle and amember as directed. I assume in your linux server you have the
following directory structure in your /home/public_html folder
Step 2: Copying required files in amember side
A. Inside amember folder go to amember plugins protect you need to create a
folder called moodle as shown below (note the directory structure is highlighted)
B. Inside the moodle folder you require three files, config.inc.php, moodle.inc.php,
readme.txt. Copy these files in to this folder and your final structure should look
like as follows:
Once these files are copied, your job is partially completed. We need to now
copy files at moodle end
Step 3: Copying required files in moodle side
A. Go to your moodle folder and your directory structure would be something like
this. You job is in the moodle/auth folder
B. You need to copy the amember authentication file inside auth folder of moodle.
You need a new folder called amember and the structure should look like this
C. Now the required authentication files should go inside this amember folder. You
have to copy three files, auth.php or lib.php, config.html, config18.html.
If you are using moodle v1.6 you need only two file, namely lib.php and
config.html, however if you use moodle v1.8 or later you need auth.php,
config.html, config18.html. Choose as per your needs.
D. Now our authentication scripts are in place and we need to create language file
for the authentication method. This we would create in moodledata folder (where
all your course files are stored). Create a folder called lang in side moodledata
E. Create en_utf8_local folder (use other lang prefix if you are using language other than english)
F. Inside lang folder you need to have custom language folder for the corresponding
language you use. This is the local language file the moodle would look for any
custom created language files. Now copy the auth.php (this is the language file
for amember authentication plugin) inside en_utf8_local folder
G. You shoud now see the folder structure something like given below
Do not bother about the moodle.php file presently. You will create this file later.
With this all the required files are in place and it now requires simple
customization of the plugins
Step 4: Enabling moodle plugin in amember
A. We now need to enable the moodle plug-in at amember side to make amember
talk to moodle database. Login in to your amember administrator page. Choose
Setup/Configuration menu under control panel to enable the relevant items
B. You will be presented with the following screen on the right side of the screen.
Click the Plugins menu from the top
C. You will now see two parts
Payment plugin, where you would choose the required payment mode for your
course, and at the bottom you would see the Protect Plugins. If your copied files
are proper in Step 1C, you would see the new moodle plug-in here. Simply
enable this plugin by checking the checkbox. Save the page. The page
refreshed and you would now be presented with the following screen
D. Note that the Moodle plug-in is now enabled. Compare with figure in Step 4B.
Click the Moodle plug-in in the top
E. You would go a new page, which prompts you enter moodle’s full path and some
conditions. Type in your moodle full path (in my case it is
/home/puchorg/public_html/testing/moodle) (in Windows it would be something
like C:\xampp\htdocs\moodle)
Save the page. If the path is correct, then the page would be refreshed
otherwise you would be prompted with error. Try to correct the path. This step is
important.
Step 5: Enabling the amember authentication at moodle side
A. It is now time to enable the amember authentication in moodle side. This
authentication plug-in enables all moodle users to get authenticated by amember
database as default. Login in to your moodle as administrator; go to users menu
on the Site Administration Block on the left. Click the authentication dialog under
Users
B. You would be presented as follows. By default Email-based self registration is
enabled. Disable this and enable aMember by clicking the eye icon. Disable
Email-based authentication and enable aMember
C. Scrolling down the page you would see the Common Settings Panel and here
you can customize the login page, and tell the first time moodle visitor, where to
go and signup. Type the correct amember signup URL in the Instructions Text
Box. It is generally http://yourdomain/amember/signup.php. Save changes
D. Now you need to tell the users how to make the payment for the courses and
register for them. To do this you need to modify the default language file
(moodle.php) and tell the user to go to product subscription page to purchase the
course. To do this go Site Administration Block and select Language editing
under Language menu
E. You would be prompted with the following screen. Choose Edit Words or
Phrases. This page would look slightly different in moodle v1.9 and v1.6
F. We need to edit moodle.php file. It is better to store the modifications in a local
directory instead of overwriting the original language file. This can be done by
first clicking the ‘Switch lang directory button’.
G. Moodle now creates a lang directory at moodledata/ folder. This is where all your
course related files are also stored. Click the moodle.php to start editing
H. Now you need to search for the phrase ‘notenrollable’. Type the instruction you
would like to give it to your customers where to go and how to purchase the
course. This is normally points toward amember/member.php (The default
amember URL for this is http://yourdomain/amember/member.php). This
instruction would be prompted every time when someone clicks the course which
he/she had not subscribed yet. Save the changes.
I. This creates the required lang file in your en_utf8_local directory as shown
Now it is the time for creating a course in moodle and make not enrollable
J. Create moodle courses as usual. Do not forget to give a SHORT NAME. This
short name is the link for amember. This name would be reflected in the
amember product setup page. Use easily identifiable names so that you do not
mix up course during product setup.
K. Make enrolment plugin as Site Default (internal Enrolment) and Course
Enrollable to NO. This is important. If someone tries to enter this course he/she
would be prompted by the instructions given in the moodle.php language file
done in the earlier step. The user can now follow the instructions given there and
take action accordingly. Save the changes.
Step 6: Creating Products in amember
A. Go to amember and login as administrator. Click the Manage products and
would be presented with the screen as given below
B. Click Add New Product link to create your products list.
C. It is better to give the first product as Free Site Registration, so that every user
can register in your moodle site for free so that they can access all guest enabled
resources. They can later purchase different courses after going through
instructions given in moodle.php language file. Set the price as 0.0 and duration
as Lifetime subscription.
D. You may now set the actual URL to which you want the user to go. Since first
product is free site registration, you can simply type http://yourdomain/moodle
which points to the moodle’s Front Page location. The link to this URL will be
created in the members page of amember so that they can directly access the
moodle page
E. At the bottom of the product page you would see the entire moodle course.
Make sure nothing is enabled for this product. This makes that the amember
user simply login in to the moodle’s front page and access only the guest
enabled courses. Save changes
F. You would see the Free Site Registration listed in the product page with URL you
typed earlier. Now we can add more products from Add New Product link
G. You add product as usual and set the appropriate Price and Duration for the
course. You may additionally add the Product URL in the text box provided.
This creates required link in the members page of amember. Users can now
directly enter in to the moodle course page without going through the moodle’s
front page. The URL for moodle course looks something like
http://yourdomain/moodle/course/view.php?id=2 and choose the correct ‘id’ of the
course. Alternatively, you may click the corresponding course in moodle and
copy the full URL from the address bar of your browser and paste it in the text
box. This is not mandatory. This only helps the user to directly go the course
page without going through moodle’s front page
H. At the bottom of the screen you select the correct course relevant to this product
by highlighting the course in Moodle Access List. As an example I have
highlighted CF101 the first course I created in the moodle earlier. Save the
changes. You have now successfully created the product and directed to the
moodle course.
In the example above I have shown a product Course 1 (point toward CF101) for
$50.00 for 30 days subscription. If you want to create another subscription say
for 6 months, for the same course, you can simply create another product with
relevant settings and enabling the same moodle course in Moodle access
dropdown box. Then you would see two different products, one for 30 day
subscription and another for 6 months subscription. This is shown in the next
screen.
I. You can see both Site Registration and Course 1 with two subscription offer in
the product’s page with relevant URL to the moodle’s page. You can create
more products for other moodle courses also.
Step 7: New user registering at Moodle
A. When a first time user goes to moodle login page he/she would be prompted with
the page (http://yourdomain/moodle/login/index.php) Click here link takes you to
amember/signup.php (see the status bar of the browser)
B. Note the correct amember URL link (http://yourdomain/amember/signup.php) at
the status bar of the browser. This would take the user to the amember signup
page. User may type in the required information
C. When this is done they would be taken to membership page
(http://yourdomain/amember/member.php)
D. Clicking on the Free Site Registration link would take the user to the moodle’s
front page. Note see that the amember user is now logged in to moodle. You can
now edit your profiles,password etc and it would be updated in the amember
database. The second time login can be done from the moodle’s default login
page.
E. If the user clicks the course (this course is our Course 1 Product in amember) he
would be prompted with this screen. This is the instruction we typed earlier in the
moodle.php language file. Users may follow the link to purchase the course
F. Uaser would be then taken to amember/member.php page. Here he/she can now
choose the course and payment method to purchase. Once payment is done the
course would be enabled under Your Subscription on the left of the screen. The
link automatically takes the member to the course page by-passing the moodle
front page.
G. The Course 1 link directs toward to the moodle course id=4 in this case.
This completes the amember moodle integration.
H. However, we need to create a common logout for both moodle and amember to
avoid any misuse. To do this edit the logout.php file in moodle (situated at
moodle/login/ )folder
I. Type the amember logout page as moodle $redirect. When user logout of moodle
he/she would be redirected to this URL. (for example:
http://yourdomain/amember/logout.php) Since this URL points toward
amember/logout.php, the user would also logout of amember at the same time.
Otherwise the user need to logout once from moodle and once from amember to
avoid any misuse.
J. In order to redirect to moodle’s front page from amember page you can set URL
in the Redirect after Logout textbox pointing towards your moodle URL. You can
access this page by login as administrator in amember and go to
Setup/Configuration from the amember control panel and selecting PHP include
menu from the top. When users log out moodle, they would logout off amember
also and amember redirects the page to moodle URL.
K. This completes the complete integration of amember to moodle. You can
customize amember templates similar to your moodle theme, so that user does
not see any difference between when they switch between amember and
moodle. This procedure also works with moodle v1.9. Consult CGIcentral
helpdesk for more help.
Thanks to CGIcentral helpdesk team for making this possible