Home > Internet > How to integrate DRM-X 4.0 with the WordPress LearnDash

How to integrate DRM-X 4.0 with the WordPress LearnDash

Added: (Wed Oct 13 2021)

Pressbox (Press Release) - 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, '