Skip to content

Instantly share code, notes, and snippets.

@mikeyhoward1977
Last active October 31, 2018 09:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikeyhoward1977/41ffb28f1a67af976f2f30a130c59bf8 to your computer and use it in GitHub Desktop.
Save mikeyhoward1977/41ffb28f1a67af976f2f30a130c59bf8 to your computer and use it in GitHub Desktop.
Redirect agents to ticket admin when they login via the Ticket Manager front end
<?php
/**
* Redirect agents to the ticket admin screen.
*
* Effective when agents login via the KBS front end login form.
*
* @param string $redirect_to The redirect URL
* @param int $user_id ID of user logging in
* @return string Redirect URL
*/
function kbs_agent_redirect_to_admin_ticket_screen( $redirect_to, $user_id ) {
if ( kbs_is_agent( $user_id ) ) {
$redirect_to = add_query_arg( array(
'post_type' => 'kbs_ticket'
), admin_url( 'edit.php' ) );
}
return $redirect_to;
}
add_filter( 'kbs_login_redirect', 'kbs_agent_redirect_to_admin_ticket_screen', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment