Skip to content

Instantly share code, notes, and snippets.

@max-kk
Last active November 19, 2020 08:57
Show Gist options
  • Save max-kk/d62ea6f15e3deaa77a69366fb6ca561d to your computer and use it in GitHub Desktop.
Save max-kk/d62ea6f15e3deaa77a69366fb6ca561d to your computer and use it in GitHub Desktop.
LRM :: filter redirect URL
<?php
// COPY AFTER to your theme functions.php
add_filter('lrm/redirect_url', function($redirect_to, $action) {
if ( 'login' !== $action ) {
return $redirect_to;
}
// Do Something with a $redirect_to, like
$url = parse_url( $_SERVER["HTTP_REFERER"] );
// CHANGE /log-in/ and /me/ to your values
if ( $url['path'] === "/log-in/" ) {
$redirect_to = "/me/";
}
return $redirect_to;
}, 11, 2);
<?php
// COPY AFTER to your theme functions.php
add_filter('lrm/redirect_url', function($redirect_to, $action, $user_id) {
if ( 'registration' !== $action ) {
return $redirect_to;
}
$user = get_userdata($user_id);
if ( !in_array("customer", (array) $user->roles) ) {
return "https://site.com/CUSTOMER/";
}
return $redirect_to;
}, 11, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment