Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save launchthatbrand/d508653415b96def73597576d9ab0e68 to your computer and use it in GitHub Desktop.
Save launchthatbrand/d508653415b96def73597576d9ab0e68 to your computer and use it in GitHub Desktop.
function require_onboarding( $can_access, $user_id, $post_id ) {
$wpflearndash = get_post_meta( $post_id, 'wpf-settings-learndash', true );
$wpflearndash = $wpflearndash['tag_link'][0];
if ( is_user_logged_in() && !current_user_can( 'manage_options' ) // if use is logged in and not an admin...
&& !wpf_has_tag( 'status - disclaimer signed' ) // and the user doesn't have the tag 'status - disclaimer signed'...
&& ( !empty( array_filter( wp_fusion()->access->get_post_access_meta( $post_id ))) || !empty($wpflearndash) ) // and the wpf settings array exists OR the learndash linked tag exists...
) {
return false; //... then access is denied.
}
return $can_access; // Otherwise use the default access rules
}
add_filter( 'wpf_user_can_access', 'require_onboarding', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment