How To: Redirect Users Away From Assignment Documentation - Honors WP

How To: Redirect Users Away From Assignment

How To: Redirect Users Away From Assignment

Table of Contents

Use this filter to set where a LearnDash user is redirected to when trying to access an assignment they do not have permission to

Getting Started #

Our documentation will require PHP and/or JavaScript code. To use the code you must place it in your WordPress code in an appropriate place to load, usually in a theme or plugin.

PHP #

PHP code can be placed in your theme’s functions.php file, or in a standalone plugin if you know how to make one.

JavaScript #

JavaScript code should be placed in a JavaScript file (.js) and enqueued using wp_enqueue_scripts. There are other ways of getting JavaScript on the page, but this is the most recommended to avoid future problems with JavaScript code on the page.

Documentation #

apply_filters( 'learndash_assignment_permissions_redirect_url',  $redirect_url );
  • $redirect_url – String – URL to redirect user to

Example #

add_filter( 'learndash_assignment_permissions_redirect_url',  'ea_redirect_assignment_permission' );
 
function ea_redirect_assignment_permission( $redirect_url ) {
    $redirect_url = get_site_url() . '/my-account';
    return $redirect_url;
}

The callback function, ea_redirect_assignment_permission should return a URL (string) of where to send the user. In the above example we redirect the user to the my account page.

Full Documentation

Shopping Cart
  • Your cart is empty.
Scroll to Top