Site icon PluginBuddy

LearnPress Social Login [Google, FaceBook, etc]

How to integrate LearnPress (LMS) with social logins like Facebook, Google, X (formerly Twitter), etc?

LearnPress social login integration helps your visitors create an account using their social media accounts. It will increase the conversion rate of your LMS. Students can easily register without complex form filling.

First, set the course in LearnPress then add correct pricing. Navigate to wp-admin > LearnPress > Courses > Select course > Pricing.

Next, Add the payment gateway, if you want to sell your course. Navigate to wp-admin > LearnPress > Settings > Payments > Click on the tick mark.

Install the Social Login Plugin

Go to wp-admin > plugins > add new > search “Nextend Social Login“. Then install it and activate it.

After that, navigate to wp-admin > settings > Nextend Social Login > Select Provider > Getting Started.

Read the complete details in the Getting Started tab. Then configure the social media account.

Finally, verify the integration from the provider tab. Then go to Global Settings> Login Form.

Change the options, refer to the image below.

Create Integration Plugin

Create a login-learnpress.php file in the wp-content/plugins folder. Then add the following code.

After that, activate the plugin from wp-admin > installed plugins.

OR

You can add the following data to selected theme functions.php file.

<?php 
/**
 * Plugin Name: Login for LearnPress
 * Description: Login
 * Version: 1.0.0
 */

add_action('login_form', 'lps_login', 33 );
function lps_login( $form ){
    ob_start();?>
    <div style="text-align: center; margin:25px 0 25px 0"> OR </div>
	<div style="text-align: center; margin: 0 auto 15px auto; width: 300px;">
	<?php echo do_shortcode('[nextend_social_login]');
	echo '</div>';
    echo ob_get_clean();
}




add_filter('nsl_google_is_login_allowed', function($atts){
    global $cart_now;
    
    $session = LP_Session_Handler::instance();
    $data = $session->get_session_data();
    $cart_now = $data;

    return $atts;
});

add_action('nsl_login', '_nsl_before_wp_login', 99);
function _nsl_before_wp_login(){
    global $cart_now; 
    
      
    $session = LP_Session_Handler::instance();

    foreach ( $cart_now as $key => $item ) {
		$session->set( $key, maybe_unserialize( $item ) );
	}    
	$session->save_data();
}

The nsl_google_is_login_allowed helps to grab data before the clear data. It is saving to gloabal cart_now variable. The nsl_login action hook helps to store cart data to session again. Then it is saving to database.

Exit mobile version