integrate with an external LMS

Home Forums Legacy Support Support queries Setup issues integrate with an external LMS

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #355076
    RMA
    Spectator
    I am trying to integrate with an external LMS. This LMS plugin requires a few properties witch is extracted from the current logged in user. The plugin that we are creating is using the built in wordpress functions to get the user. "wp_get_current_user()", "is_user_logged_in()","get_current_user_id()". We then add a shortcode to the "LMS -> Unit", witch will pull the external content into an iframe. But without the current user context, it cannot function. When tested outside the course/unit page, it works. When using the shortcode inside the course page it does not get the current logged in user. So my question is, how can we modify this plugin to get the current logged in user so we can extract the following required fields: "user_email","user_firstname","user_lastname","user_id" Do you have some global function that the plugin can use to extract this info from the current logged in user?
    #355556
    Anshuman Sahu
    Keymaster
    Here is how you can add to content : please try adding this given code in your wplms-customizer.php file in wplms customizer plugin : this code will append your user id based dynamic content to the unit content .
    
    add_filter( 'bp_course_api_get_user_course_status_item',function($return, $request ){
        $body = json_decode($request->get_body(),true);
        if(!empty($body['token']) && is_numeric($request['course'])){
            
            $user = apply_filters('vibebp_api_get_user_from_token','',$body['token']);
            $user_id = $user->id;
        }
        if(!empty($user_id)){
            //do your thing here and add the content to :
    
            ob_start();
           echo 'your dynamic content';
    
            
              
    
            $cont =  ob_get_clean();
    
            $return['content'] .= $cont;//here the content is appending in api call return 
        }
    
        return $return;
    },10,2);
    #356137
    RMA
    Spectator
    Thank you.
    #356207
    Veronica
    Moderator
    good to know this helps you
Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘integrate with an external LMS’ is closed to new replies.