llms_update_343_update_relationships()

Rename meta keys for parent section and parent course relationships for all LifterLMS Lessons and Sections


Description Description


Source Source

File: includes/functions/llms.functions.updates.php

function llms_update_343_update_relationships() {

	global $wpdb;

	// update parent course key for courses and lessons
	$wpdb->query( "UPDATE {$wpdb->postmeta} AS m
		 JOIN {$wpdb->posts} AS p ON p.ID = m.post_id
		 SET m.meta_key = '_llms_parent_course'
		 WHERE m.meta_key = '_parent_course'
		   AND ( p.post_type = 'lesson' OR p.post_type = 'section' );"
	);

	// update parent section key for lessons
	$wpdb->query( "UPDATE {$wpdb->postmeta} AS m
		 JOIN {$wpdb->posts} AS p ON p.ID = m.post_id
		 SET m.meta_key = '_llms_parent_section'
		 WHERE m.meta_key = '_parent_section'
		   AND p.post_type = 'lesson';"
	);

}

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.





Permalink: