sensei-certificates
sensei-certificates copied to clipboard
Add support for bulk downloading certificates
The user in #1192327-zen has over 4,200 certificates that they need to download and save. Can we enable/add bulk downloading of certificates?
+1 on forum thread: https://wordpress.org/support/topic/how-to-export-all-certificates/
@m1r0 is it worth logging this also in the Sensei repo or logging it here is enough?
Here is good. Thanks, Stef.
Thank you all for looking into it! In the meantime - Does anyone know of any technique to download them all quickly (easier than clicking on each one?). Do you all know how I can get a list of all the certificate urls? I might be able to write a cron / php script to get them... (thinking out loud sorry) thank you all for your help 🙏
Hey @Tison, the certificates are stored as posts so for getting all URLs, something like the following might do the trick:
add_action( 'wp_loaded', function () {
$certificates = get_posts( [
'post_type' => 'certificate',
'posts_per_page' => -1,
'post_status' => 'publish',
] );
foreach ( $certificates as $certificate ) {
$url = get_permalink( $certificate->ID ); // -> https://sensei.test/certificate/5370cfee/
}
} );
For generating the PDFs, you can try:
$hash = get_post_meta( $certificate->ID, 'certificate_hash', true );
$pdf = new WooThemes_Sensei_PDF_Certificate( $hash );
$pdf->generate_pdf();
Hope this helps. 🙂
@m1r0 This is helpful in the meantime! I will give it a try, thank you