Home › Forums › Legacy Support › Support queries › How-to & Troubleshooting › Add condition to certificate generation
Tagged: certificate
- This topic has 5 replies, 2 voices, and was last updated 4 years, 12 months ago by logan.
Viewing 6 posts - 1 through 6 (of 6 total)
-
AuthorPosts
-
December 13, 2019 at 12:46 pm #236813mine-classParticipantHi 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":[]}
December 16, 2019 at 11:11 am #237012loganMemberHello, where do you want to add this- when user completes 100% and completes the course OR
- when admin assigns this manually from the admin section.
December 16, 2019 at 1:02 pm #237033mine-classParticipantWhen the user finished and approve the course.December 17, 2019 at 12:24 pm #237122loganMemberhere 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);December 24, 2019 at 1:54 pm #237667mine-classParticipantHi 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" ?December 26, 2019 at 12:46 pm #237747loganMemberuse 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); -
AuthorPosts
Viewing 6 posts - 1 through 6 (of 6 total)
- The topic ‘Add condition to certificate generation’ is closed to new replies.