@karlikdesign,
2 things I see here:
1) If I don’t have it documented it’s because I’m exhausted and mostly alone… hook into the filter at: https://github.com/gocodebox/lifterlms/blob/master/includes/functions/llms.functions.access.php#L149
This will $results
array passed into the filter will look like this when the user has access:
array (size=4)
'content_id' => int 1961
'is_restricted' => boolean false
'reason' => string 'accessible' (length=10)
'restriction_id' => int 0
And something like when the user is not enrolled (or if the user is logged out):
array (size=4)
'content_id' => int 1961
'is_restricted' => boolean true
'reason' => string 'enrollment_course' (length=17)
'restriction_id' => int 1961
(Excuse the xdebug output, you get the idea right?)
So you could do something like this to redirect to a sales page *only when the user is not enrolled*
add_filter( 'llms_page_restricted', function( $results, $post_id ) {
// redirect if the content is a course and the user is not enrolled (the content is restricted)
if ( 'course' === get_post_type( $results['content_id'] ) && $results['is_restricted'] ) {
wp_redirect( 'https://mydomain.tld/my/sales/page' );
exit; // important b/c of WP reasons I can't recall but always abide by...
}
// do default stuff otherwise
return $results;
}, 10, 2 );
(If you’re not into closures don’t use the closure, you get the idea, right?)
As far as your thank you page redirect, in 3.x we added this: https://lifterlms.com/docs/lifterlms-filters/#lifterlms_completed_transaction_redirect
This may help you stay away from a plugin and a regex, but I wanted to let you know about it anyway.
Hope that helps,