Add condition to certificate generation

Home Forums Legacy Support Support queries How-to & Troubleshooting Add condition to certificate generation

Tagged: 

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #236813
    mine-class
    Participant
    Hi I'm struggling with something. I need that the course certificate is only generated if an external condition is meet (student have to sign a document in an external system). I have created a very simple API hosted in the same server that receives the wp user_login and the course_id (and a key) and answers if he had signed the document in the external system (true or false). I was wondering if you guys can develop something that allow to the student to obtain his certificate only if the API says that he has trully signed (signed=true), and if he has not signed (signed=false) show him a message provided by the same API.  
    • example API request: https://guru-class.com/api/signed/?key=AAA&user=BBB&course=CCC
     
    • example API response signed: {"data":{"user":"BBB","course":"CCC","signed":true},"metaData":[]}
      -example API response not signed: {"data":{"user":"BBB","course":"CCC","signed":false,"message":"this is a custom html message"},"metaData":[]}   Thanks in advance
    #237012
    logan
    Member
    Hello, where do you want to add this
    1. when user completes 100% and completes the course OR
    2. when admin assigns this manually from the admin section.
    #237033
    mine-class
    Participant
    When the user finished and approve the course.
    #237122
    logan
    Member
    here it is: add_filter('bp_get_course_check_course_complete_stop',function($flag,$id,$user_id){ $response = wp_remote_get('https://guru-class.com/api/signed/?key=AAA&user='.$user_id.'&course='.$id); $message = ''; if(!empty($response) && !is_wp_error( $response )){ $body = wp_remote_retrieve_body( $response ); if(!empty($body)){ if(!$body->data->signed){ $flag = 0;   }else{ $flag = 1; $message = 'Document not signed'; } }else{ $flag = 1; $message = 'Some error appeared from signing server'; } }else{ $flag = 1; $message = 'Some error appeared from signing server'; } if($flag){ echo $message; } },10,3);
    #237667
    mine-class
    Participant
    Hi The code works well, it throws the message but it still generate the certificate. How can we make to not generate the certificate until the API says "signed=true" ?  
    #237747
    logan
    Member
    use this code instead of above: add_filter('bp_get_course_check_course_complete_stop',function($flag,$id,$user_id){   $response = wp_remote_get('https://guru-class.com/api/signed/?key=AAA&user='.$user_id.'&course='.$id);   $message = '';   if(!empty($response) && !is_wp_error( $response )){   $body = wp_remote_retrieve_body( $response );   if(!empty($body)){   if(!$body->data->signed){   $flag = 0;       }else{   $flag = 1;   $message = 'Document not signed';   }   }else{   $flag = 1;   $message = 'Some error appeared from signing server';   }   }else{   $flag = 1;   $message = 'Some error appeared from signing server';   }   if($flag){   echo $message;   } return $flag; },999,3);
Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Add condition to certificate generation’ is closed to new replies.