Skip to content

Instantly share code, notes, and snippets.

@femiyb
Created October 18, 2019 16:13
Show Gist options
  • Save femiyb/b11bd04c431e4f920eac9d42b811c992 to your computer and use it in GitHub Desktop.
Save femiyb/b11bd04c431e4f920eac9d42b811c992 to your computer and use it in GitHub Desktop.
<?php
/**
* Redirect users to aacount page after login
*/
function pmpro_redirect_after_login( $redirect_to, $request, $user ) {
if ( isset( $user->roles ) && is_array( $user->roles ) ) {
//check if user is not an admin.
if ( !in_array( 'administrator', $user->roles ) ) {
$redirect_to = home_url('membership-account');
}
}
return $redirect_to;
}
add_filter( 'login_redirect', 'pmpro_redirect_after_login', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment