Can someone help me with this? I am using wordpress and create an html tag to create a link. I wanted to know if it is possible that this link redirects users according to their role. I understand that for this I must use php but I could not find the proper code. This is what I could do but it does not work.
<?php
$current_user = wp_get_current_user();
$role_name = $current_user->roles[0];
if ('vendor' === $role_name) { wp_redirect(get_site_url() . '/dasboard'); exit();
if ('customer' === $role_name) { wp_redirect(get_site_url() . '/my-acount'); exit();
?>