wp_loaded hook runs before WordPress has setup postdata so you won’t be able to get there the information you need.
The earliest hook you can use to have that information should be wp.
You can use is_author() to check if you’re on an author page and is_user_logged_in() to check if the user is logged in:
function zb_user_analyze() {
if( is_author() && !is_user_logged_in() ) {
$author_id = get_query_var( 'author' );
// do something
}
}
add_action('wp', 'zb_user_analyze');
Related Posts:
- How do I get the current edit page ID in the admin?
- Use author author display name in permalink structure for pages and posts
- Possible to search by author name with default WordPress search function?
- Can’t get post ID in functions.php?
- Add admin bar link to edit author
- Get user id from email?
- Authors details such as social media links, emails etc → Is this Meta or something else?
- Display the number of user comments
- Hide Author.php template from specific user role
- How to automatically remove links from WordPress Biographical Info?
- Commenter should see only his comments in wordpress
- Allow Post Author to be 0 on Update
- wp-comment author- url +, email filter hook
- check if author has published posts in custom post type, then send mail
- Author Date Function not working as expected [duplicate]
- How to Extend login session times to a Month
- Disabling Author Page only for subscribers
- If no author posts, echo out some text
- get_current_user_id() always return 0 in if else statement
- Get post_author email for Zapier Integration
- Author social media aren’t shown on the page
- How To Display Author Popup on Entry Meta (Genesis Framework)?
- Author info does not show up when author has no posts
- Show the online status of the current post’s author
- Syling Custom Fields echo’s from from functions.php
- Using array page name together with page id to deregister script
- get USER ID in functions.php using user_register action
- How to Insert A List of Posts in A Category Written by the Author into the Author Archive
- How to add user_registered time in human_time_diff() wordpress
- Include posts under a custom taxonomy in author.php
- Missing feature image link function
- What’s the difference between home_url() and site_url()
- Remove “Category:”, “Tag:”, “Author:” from the_archive_title
- get_template_directory_uri pointing to parent theme not child theme
- How to customize the_archive_title()?
- remove empty paragraphs from the_content?
- What is the “with_front” rewrite key?
- Why use if function_exists?
- How to override parent functions in child themes?
- wp_enqueue_script was called incorrectly
- Add multiple custom fields to the general settings page
- Ajax call always returns 0
- 400 bad request on admin-ajax.php only using wp_enqueue_scripts action hook
- How long does a deprecated function live in core?
- Solution to render Shortcodes in Admin Editor
- How to add a data attribute to a WordPress menu item
- get post author id outside loop
- What’s the difference between esc_html, esc_attr, esc_html_e, and so on?
- remove_action on after_setup_theme not working from child theme
- plugins_url vs plugin_dir_url
- Remove type attribute from script and style tags added by WordPress
- How to get Author ID outside the loop
- How to run a function every 5 minutes?
- Best way of passing PHP variable between partials?
- Upload Multiple Files With media_handle_upload
- How to display custom field in woocommerce orders in admin panel?
- Adding fields to the “Add New User” screen in the dashboard
- Issues with title-tag and document_title_parts
- How to check if a user exists by a given id
- Echo author ID in author.php
- Why isn’t is_page working when I put it in the functions.php file?
- Add tags to the section via functions.php
- Add image size if page template
- How to create a custom order status in woocommerce!
- Remove Actions/Filters added via Anonymous Functions
- Adding a second email address to a completed order in WooCommerce [closed]
- How to load parent_theme functions.php before child_theme?
- How to load scripts/styles specific for a page
- Programatically add options to “add new” custom field dropdown
- Is there any global functions.php file which works for any theme?
- Excluding iPad from wp_is_mobile
- When should you, and when should you not, use wp_list_pluck()?
- Get the ID of the page a menu item links to?
- Add container to nav_menu sub menu
- Difference between the_permalink() and get_permalink() function
- What’s the difference between WordPress random_int() and PHP built-in function random_int()?
- Child theme – Overriding ‘require_once’ in functions.php
- Link to user’s profile settings page?
- WordPress Enqueue for homepage only, functions.php, wp-framework
- get php variable from functions php and echo it in theme template files [closed]
- Get menu object from theme_location
- Is it ok to use a function to output the text domain name in a wordpress theme
- Displaying the number of updates available in the Admin area
- Trying to use add_action and do_action with parameters
- Use AJAX in shortcode
- Set JPEG compression for specific custom image sizes
- Can the new 4.8v text widget visual editor be removed?
- Prevent “main” WPMU site_url() being returned in functions
- Include files in child theme functions file
- Memorizing syntax
- Custom page with variables in url. Nice url with add_rewrite_rule
- Define page template in wp_insert_post
- Which WP functions do you need to use esc_html() or esc_url() on?
- Check if post is being published for the first time, or is an already published post being updated
- Display random categories on the front page (Finding and Editing Theme Functions)
- How to redirect to post if search results only returns one post
- remove links from images using functions.php
- Order posts (across the whole site) by metadata date
- Is it possible to rename a post format?
- Why does WordPress have private functions?