Depends on whether or not you need to check against WordPress’ user authentication. If you need to know whether they’re a logged in user, hook onto 'init'
. Otherwise, the sooner the better.
If it’s something that should fire on every page load, and only checks for existence of the cookie and doesn’t need to tap into any of WP’s APIs, I’d put it into a custom MU-plugin named 0000a.php
to ensure that it fires before any non-core files could accidentally send headers.
Related Posts:
- Find variables available at a given hook
- Why do filters/actions require an argument count?
- How to use return in my custom function instead of echo
- add_action shortcut?
- Is it acceptable to treat a filter like an action?
- Contact Fom 7 – how to add custom HTML inside span.wpcf7-form-control-wrap AND IMMEDIATELY AFTER input.wpcf7-form-control?
- Insert custom PHP head above in WP pages
- Override a function defined in wp-includes/comment-template.php
- Add meta tags to a custom header
- Dynamically adding filters
- setcookies and header send
- How to internationalize header image?
- How to remove get_header From all single pages in wordpress with functions.php without plugin?
- I want to hide “sold by” on certain pages with id page 43
- How to add custom checkout field in user details mail template
- Cannot modify header information – headers already sent
- How to change wp-admin and wp-login urls
- Is there a hook that I can use when a fatal error occurs?
- Show post in elementor based on views and specific category with query id feature in elementor
- Why does my callback function not work with this custom filter hook?
- Responsive Header for Phone
- Removing “wpautop” (auto tags) only on certain pages?
- Trying to place a custom field after the total section in the checkout page in woocommerce
- Add filter when image is uploaded?
- Remove the first 5 characters of the_title and orderby that
- Remove a div from RSS feed
- Print last modified date only on posts
- How to store post ID’s in cookie or session to display the same posts later
- How to properly modify WP Vary or any existing headers?
- Set meta field to publish date + 2 weeks
- How to add an arrow to menu items has submenus
- WordPress Gravatar filter is removing my custom attributes
- Generating an nonce for Content Security Policy and all scripts – How to make it match/persist for each page load?
- how can i use $_COOKIE[] + PostID to execute the below code?
- Adding widgets to my plugin page instead of WordPress dashboard
- Unique icons next to each WordPress menu item
- iframe does not store session/cookie when refresh parent
- action theme mailchimp subscriber fields
- Adding function to Genesis genesis_header [closed]
- My php header() function is not working [closed]
- Modify custom field input data before creating a new post
- Change tinyMCE editor to allow marked content when pasting from Word
- “imagejpeg” function is not working in wordpress
- wp-comments-post.php file returns a blank page
- Problem with login form
- Headers already sent in Pluggable.php / homepage and wp-login error
- Is_front_page inside header.php is always returning true
- Does wordpress templates always in files or in database?
- Error call_user_func_array() expects parameter 1 to be a valid callback when using image_size_names_choose
- jQuery code not working when included in functions.php
- Adding Meta Tags to a Post using its Tags, Excerpt and content
- Alter required message using comment form api
- How to debug this search & replace strings snippet?
- add_action taking an array with the 2nd argument?
- Hide Featured Image Meta Box on Editor Screen
- Add item to top of menu using a filter in functions.php
- Should `wp_login` be used since it’s deprecated?
- Moving code from theme header to functions.php
- Add filter multiple times using only one master function
- How to edit php code in WordPress Post file?
- How to show a users bio on a page
- Change page title from page using php via php executed from page/post itself
- How to make modifications only to certain elements of an HTML string on the server-side?
- WordPress wp_redirect error
- Having Issue on Redirecting With Session in WordPress
- Nested “do” and “add” Actions is possible?
- Change order of custom submenu link in WP Admin?
- Filtering a function’ output for a new continued function
- linking stylesheets and scripts with functions.php
- My php code is not being executed
- Location of core code for database connection and get_header
- Deleting Certain terms from appearing on the front end as links
- Clickable image link sends people to wrong URL
- Content filter won’t work
- unknown issue in ‘header.php’ preventing theme from displaying fully
- How can I use a sliced image As banner? [closed]
- How to catch wordpress post ID when it’s published
- WordPress redirect redirecting too many times or not at all
- Warning: in_array() null given in PHP function
- Upload multiple files in randomly generated folder using wp_upload_bits
- Create page template via functions.php?
- Ajax filter button display all posts
- How to append to an array and return the results in a filter?
- $_SESSION variable not saving on page refresh or new page
- How to have different site identity logos on each page on Astra Theme [closed]
- Is this a correct usage of ob_start() in my WordPress project?
- Can not add admin notices from the edit_user_profile_update hook (notices not being displayed)?
- How to pass argument to add_action while the method is inside a class?
- Display attribute on shop page after the title
- How do I create a secondary version of the_content
- Get the_content surrounded by instead of
- Custom query vars filters problem with pagination
- Filter by field with array value in ACF on WP REST API
- Change header on pages displaying taxonomy items
- wrap a span tag around author’s post count
- Get the name of menu item with wp_nav_menu
- Action Hook Inside WordPress Plugin Shortcode
- Displaying content on posts page based on category
- How to set cookies
- update_post_meta() not saving data inside of save-post filter