Redirect based on user and current page functions.php
<p>I'm looking for a piece of code to add to my wordpress site to redirect certain users based on their role but only when they get to a certain page.</p>

<p>I need this to show a specific page to a specific user role and not the one others get. A plugin won't do in my scenario.</p>

<p>I'm not just looking for a redirect in php. 
I need to make something that will work in 3 steps:</p>

<p>First I need to check if the user/visitor is on the desired page. </p>

<p>After that I need to check for a specific user role (I got this covered).</p>

<p>And at last to redirect (got that coverd to).</p>

<p>I have no idea how to accomplish the first step inside the functions.php and if my flow even makes sense..</p>

<p>Edit: Solved!</p>

<pre><code>add_action('template_redirect', 'redirect_user_role'); 

function redirect_user_role()
{ 
    if(current_user_can('subscriber') &amp;&amp; is_page(' ID, Slug or name here ')) 
    { 
        wp_redirect('https://www.example.nl'); 
    } 
}
</code></pre>