• Resolved mrklc

    (@mrklc)


    Hi all;

    Is it possible to restrict the download link for a particular role? I can restrict the page / post that shows the link but once ppl has the URL of the link, they can download it without logging in, right?

    Thanks.

    Cheers,
    K

Viewing 1 replies (of 1 total)
  • Plugin Author Caseproof LLC

    (@caseproof)

    Hi @mrklc

    We don’t provide redirection for download link, but you can try to use this code snippet:

    add_action( 'template_redirect', function() {
      // Redirect users from specific page 
      // when user doesn't have particular role 
      $user = wp_get_current_user();
      if ( is_page('contact') && ( ! is_user_logged_in() || ( ! empty($user) && in_array( 'author', (array) $user->roles ) ) ) ) {
        $redirect = 'https://your-domain.com/unauthorized'; // Change this to the correct URL
        wp_redirect( $redirect );
        exit;
      }
    } );

    Hopefully, that helps.

Viewing 1 replies (of 1 total)

The topic ‘Restricted download link’ is closed to new replies.