• Resolved aprettierweb

    (@karlikdesign)


    Hi Thomas!

    So I’ve been trying to hunt down your redirection features! It seems from Trello that a redirection feature was added in 3.x and from the documentation that there was a workaround for 2.x. but it seems to no longer work in 3.x

    I have a workaround right now with the “redirection plugin” that new purchasers get sent to a THANK YOU page (based on url and referral). I’m happy with that

    BUT I would love love love…

    to ALSO redirect people to sales page instead of the course page if they are not enrolled in that course….

    Anyway, wondering if redirection exists somewhere and I’m blind?

    Still so in LOVE with LifterLMS!

    Thanks,
    Mel

Viewing 3 replies - 1 through 3 (of 3 total)
  • @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,

    Thread Starter aprettierweb

    (@karlikdesign)

    That’s perfect. Thanks Thomas. You are always so quick to reply!!

    (I think you’re doing a great job handling all of the tech questions!!)

    Mel

    @karlikdesign,

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Redirection’ is closed to new replies.