Skip to content

Instantly share code, notes, and snippets.

@verygoodplugins
Last active December 6, 2022 10:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save verygoodplugins/9f12ecec54f3c5605d29df60d293e198 to your computer and use it in GitHub Desktop.
Save verygoodplugins/9f12ecec54f3c5605d29df60d293e198 to your computer and use it in GitHub Desktop.
Copies Memberium's LearnDash auto-enroll tags over to WP Fusion's Link With Tag setting
<?php
function maybe_migrate_auto_enroll_tags() {
// visit /wp-admin/index.php?migrate=true to start.
if ( isset( $_GET['migrate'] ) ) {
$linked_courses = get_posts(
array(
'post_type' => 'sfwd-courses',
'nopaging' => true,
'meta_query' => array(
array(
'key' => '_is4wp_learndash_autoenroll',
'compare' => 'EXISTS',
),
),
'fields' => 'ids',
)
);
if ( ! empty( $linked_courses ) ) {
foreach ( $linked_courses as $course_id ) {
$setting = array(
'tag_link' => array_values( array_filter( explode( ',', get_post_meta( $course_id, '_is4wp_learndash_autoenroll', true ) ) ) ),
);
update_post_meta( $course_id, 'wpf-settings-learndash', $setting );
}
}
}
}
add_action( 'admin_init', 'maybe_migrate_auto_enroll_tags' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment