It will be bit tricky to detect if user just get into site. But generally there will be no referer, hence wp_get_referer()
will return false
.
My code check if there is referer, if no then they get redirected to post page.
NOTE:
When user access a page in admin by typying url in adressbar then
redirect is applied to them also, because there are no referer.
This a simple solution, based on referer. It can be improved more.
/**
* Redirect user if there is no referer.
*
* @return void
* @author Rahul Aryan <[email protected]>
*/
function my_redirect_users(){
global $pagenow;
/* Check current admin page. */
if($pagenow != 'edit.php' && !wp_get_referer()){
wp_redirect(admin_url('/edit.php?post_type=st_kb'));
exit;
}
}
add_action('admin_init', 'my_redirect_users');