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');
Related Posts:
- How to manually activate user in dashboard only by admin
- How do I create a new WP admin color scheme?
- Change labels on ‘Nickname’ and ‘Biographical Info’ in user-edit.php
- I changed “Howdy” in the admin bar in the dashboard, but when I’m viewing the site it still says Howdy!
- Create dropdown of users in admin dashboard
- Display WooCommerce subscriptions for user [closed]
- Adding widget to dashboard with wp_dashboard_setup not working
- Dashboard widget custom positioning?
- Sortable column (by numbers) in admin users
- How to remove some item from WordPress Dashboard for user Author
- Add Link to Users List (Backend) to open each users front-end profile
- hook for dashboard show_user_profile
- How to display my comment count in the wordpress admin bar?
- Remove theme, change theme button and WP version on “Right Now” admin dashboard?
- Code in functions.php appearing on front-end and dashboard [closed]
- Get the ID of the page a menu item links to?
- Add container to nav_menu sub menu
- One Child Functions.php for Multiple Child Themes
- Disabling pingback and trackback notifications
- register_post_type for Pages?
- Paged Single Post doesn’t redirect to the main url after Removing Pagination
- How to get comments with mixed status using get_comments?
- How to display the_post_thumbnail if a post has one or otherwise display the first image in a post?
- How to add .htaccess code through a function?
- Conditional tag is_page with a custom post type
- How can I rename the WordPress AJAX URL? [duplicate]
- How to add a rel attribute to images that contains their categories?
- Is it possible to be more page/post specific with admin_enqueue_script?
- Enqueue script o style only if a template part is loaded
- radio button is checked but display not check
- Theme options WP Editor
- Can I pass two roles to the function get_users?
- Properly applying nonce to a form using AJAX
- What is the $context in remove_meta_box function?
- Add external js file to footer with id
- Conditions for Users and Visitors
- add_filter priority problem
- wp_enqueue JavaScript in child-theme (ReferenceError) using Search & Go
- How can I enable uploading excel files?
- Enqueue scripts not working with if is page conditional tag in functions.php
- Why does the ‘wp_nav_menu’ function work only until a menu is created?
- How to customly read JWPlayer’s “Playlist” items by using its “playlistid”?
- Twentyten Child Theme: header images display messed up in admin panel
- Removing wp_login_viewport_meta
- Get Current Post ID in functions php, meta query filter
- Jquery implementation not working on page reload
- Parse error after modifying the template menu [closed]
- Move Custom Fields on General Settings Page to New Location
- Remove adjacent_posts_rel_link under 3.2?
- enqueue_script with filemtime javascript not working
- Pass parameter to hooked function using custom page template
- How to obtain the recent posts without their content in an efficient way?
- Limit dimensions of “Full” size images
- Where to put random functions?
- Define PHP variable from a seperate API if statement
- content editor format style tags
- Custom Behavior when Adding New Custom Post Type in Dashboard
- Function not working inside of a function in functions.php
- How to Use Global Variables Inside Header and Footer
- Does size of a theme’s functions.php file matter?
- How to add custom user avatar in wordpress
- Redirect website domain (including all pages) to external URL after Popup message (few seconds)
- Where do I go to edit this area? [closed]
- Enable right click on WordPress site
- Check from functions.php if function exists in footer.php
- This code works, but the way I integrated it is breaking the media uploader. How can I integrate it properly?
- Email Exists ERROR into Ajax registration form
- How to overwrite template.php file
- Limit number of characters in different excerpts
- How to avoid saving empty data to sql while using add_meta_box
- How to assign php file(template) to several pages with same prefix page name/slug
- Is this a backup door?
- How to fix Function create_function() is deprecated in / themes
- Block all plug-ins from initiating redirection upon activation?
- custom error message for empty username and password using authenticate filter not working
- Modifying a WordPress Plugin
- Last updated posts shortcode in functions.php
- I have an fatal error on my funcyions.php
- Get post_author email for Zapier Integration
- get_locale() is different from $locale
- If click on Save/Publish change Post Status to Pending Review instead Publish
- Remove all video attachment, both files and post/postmeta from database?
- Remove the delete link from pages without a plugin
- Custom download page
- HowTo: Add wrapper to columns shortcode?
- How to include a hyperlink in the body text of a custom password protected form?
- Get title from IDs in a string
- uninstall a theme programmaticlly
- Could you please correct the code is_admin()
- Dynamically generated Navigation Diagram using Custom Fields
- Update add_image_size
- Function to get the name in database table from the comma separated string
- Full size image option removing problem
- Limit length of headline in Editor
- Way of getting queried loop before the query with a filter hook?
- Why my wp_enqueue_script doesnt work on some page?
- Need to use an external variable inside a function
- Trying to get this function to show below the content
- is_preview() always return false
- comment_post function with js not running