How to integrate DRM-X 4.0 with the WordPress LearnDash
Added : (
Wed Oct 13 2021
)
LearnDash is an open source LMS online education plug-in for Wordpress, and it is the most popular education system in the world. LearnDash is mainly used in universities, training institutions and enterprises, and is the first choice for creating and selling online videos. LearnDash can easily create and sell courses, provide questions and answers, reward certificates, manage users, download reports and other functions.
Haihaisoft DRM-X 4.0 platform provides digital rights management solutions. You can easily and securely publish digital content protected by DRM-X encryption on computers and the Internet, such as videos, music, movies, documents, PDF e-books, etc., So that you can get rid of the trouble of being unable to effectively deliver and sell these contents due to piracy issues.
DRM-X 4.0 provides an XML Web service interface, making it easy for you to seamlessly integrate your website with the DRM-X 4.0 platform. You can completely customize the license page. You can use the current website's course system and shopping cart system, which will provide end users with a better user experience.
Next, we will introduce how to use the DRM-X 4.0 interface to integrate with your WordPress LearnDash online education system.
To prepare for integration, please install the LearnDash plug-in on your website and create a test course.
Step 1: Download and modify the integration code.
1. Download the sample code, DRM-X 4.0 Wordpress+LearnDash integration sample code
Download and unzip the integration code, you will see the following directory structure:
CSS Style folder
Images Image resource
Includes Referenced third-party library
-- drm_config.php Database configuration and DRM-X 4.0 integration parameter setting
-- drm_functions.php Method of calling DRM-X 4.0 interface
-- drm_nusoap.php Network service interface class, used to call the interface provided by DRM-X 4.0
index.php The first page of the integration obtains the parameters returned by the client and verifies the user's login information.
login.php It is used to verify whether the user has joined the current course and call the DRM-X 4.0 interface. You can add the code you need on this page according to your business model.
licstore.php The license storage page, it is forbidden to modify the file name of the file, and the license storage must use this name.
LicError.php Error display page during license acquisition.
2. Modify the integration code
After understanding the directory structure of the sample code, start to modify the integration code below.
First edit includes/drm_config.php to modify the configuration file.
The configuration file includes database connection configuration and DRM-X 4.0 integration parameter settings.
/**
* For the database configuration of your website, you can refer to the wp-load.php file of your website
*/
define('DB_HOST', 'localhost');
define('DB_USER', '');//Required, please enter the database user name
define('DB_PASSWORD', '');//Required, please enter the database password
define('DB_NAME', '');//Required, please enter your WordPress database name
/**
* DRM-X 4.0 integrated parameter setting
*/
define('WSDL', 'https://4.drm-x.com/haihaisoftlicenseservice.asmx?wsdl');
define('ADMIN_EMAIL', ''); //Required, Your DRM-X 4.0 email account
define('WEB_SERVICE_AUTH_STR', ''); // Required, DRM-X 4.0 Web Service Authentication String. http://4.drm-x.cn/SetIntegration.aspx
define('RIGHTS_ID', ''); // Required, DRM-X 4.0 Rights ID
define('GROUP_ID', ''); // Required, DRM-X 4.0 Group ID
After the configuration file is modified, open the first page of the integrated login.
Index.php, the php file stores the parameters for obtaining the license sent by the client through the session (it must be obtained on the first page of the integration, the index.php page)
$_SESSION['ProfileID'] = $_REQUEST["profileid"];
$_SESSION['ClientInfo'] = $_REQUEST["clientinfo"];
$_SESSION['Platform'] = $_REQUEST["platform"];
$_SESSION['ContentType'] = $_REQUEST["contenttype"];
$_SESSION['ProductID'] = $_REQUEST["yourproductid"];
$_SESSION['RightsID'] = $_REQUEST["rightsid"];
$_SESSION['Version'] = $_REQUEST["version"];
$_SESSION['Return_URL'] = $_REQUEST["return_url"];
Then in the code, you can see the use of wp_get_current_user() to obtain the user’s login information to determine whether the user has logged in to the website. If the user has already logged in to the website, it is directed to login.php for the next step of verification. If the login expires or there is no login to the website, it will Prompt the user to log in to the website again.
Login.php is mainly used to verify whether the user has registered for the current course and get the validity period of the current course. Then call the DRM-X 4.0 interface to perform user detection, update Rights, and obtain licenses.
We have added detailed comments in login.php, you can add or modify the code according to your business model and needs.
When all verifications are passed, it will be directed to licstore.php, please do not modify the file name of licstore.php.
In the licstore.php file, we only did two things.
1. Storage License
To store the license, you only need to output the license under the tag.
echo $license;
?>
2. Determine whether the license has an error message
if(stripos($license, '' ) === false ){
header("location:LicError.php?error=".$license."&message=".$message);
exit;
}
One more thing you need to pay attention to in the licstore.php file is to output $_SESSION["Return_URL"] in
. Only when Return_URL is set in , the integration code can correctly return to the course playback page.
The last page, LicError.php is used to display error messages. You can display more complete and friendly error messages on this page according to your needs.
The integration code has been modified, please upload your modified integration code to the root directory of your website, then log in to your DRM-X 4.0 account, go to "Account Settings"-" Website Integration Preferences", select “Custom login page integration”, enter the License URL.
Step 2: Associate website courses with DRM-X 4.0 License Profile
Visit the course list on your website, find the encrypted course you want to test, move the mouse to "Edit", you will see the course ID in the URL below. Then record the secondary ID number.
Visit the License Profile page of the DRM-X 4.0 account, add a new License Profile, enter the License Profile name, and select the Rights set in the configuration file (drm_config.php).
Set the course ID you just viewed in " ProductID in your system", and then save it.
Please refer to the screenshot below:
DRM-X 4.0 License Profile:
At this step, the course and License Profile of your website have been associated with each other.
Step 3: Embed encrypted video into the course
Edit the lesson and add a "Custom HTML" block.
As shown below:
Copy the code below and modify the video URL in the code.
https://www.coursology.org/drm-integration/Forever_Reign_P.mp4
After completing the above steps, the integration with LearnDash has been completed. If you have any questions during the integration process, please contact us.
How to integrate DRM-X 4.0 with the WordPress LearnDash
Submitted by:
No Contact Details Supplied
Add your
press release for free.
Find
out more.