The $current_user
global isn’t setup until right before the 'init'
action is called. So any code using it shouldn’t be fired until that action or later.
I would also suggest using the get_current_user_id()
method instead of getting the global directly.
Related Posts:
- Is it ever okay to include inline CSS in plugins?
- Is it mandatory to use $wpdb->prefix in custom tables
- add_action hook for completely new post?
- Is get_option function cached?
- How do I log plugin (cron) actions?
- Is there a hook for when you switch themes?
- Problems after wp_set_password() containing an apostrophe
- Error getting correct blog_id on MU from functions.php
- product-attribute-slug-is-too-long-28-characters-max
- Front-End Form Submission in Shortcode
- Confusion on WP Nonce usage in my Plugin
- Plugin Localization
- Error : “Updating failed: The response is not a valid JSON response” with custom shortcode
- array_map() for sanitizing $_POST
- Add media and attach images to pages
- Why cant the WP Filesystem API read googlefonts.json?
- calling jquery function on plugin page
- Is there a faster way than wp_insert_post to add content to a blog
- How to include external library in wordpress plugin
- Show comments fields in two columns
- Ajax in WordPress – path issue
- How to determine if the current file is loaded in a plugin or in a theme?
- Decrease RSS cache time in plugin?
- Which action is triggered when a theme was modified?
- Check if someone is editing a post (this content is currently locked)
- How to add a custom tag in contact form 7 and change the output in email?
- WordPress setting with select – where is my mistake?
- How can I create a plugin that changes the title color of a website?
- How to check if Woocommerce Order number equals to post ID?
- Add custom element ID depending where the widget place is, sidebar or footer
- Two functions utilizing registration_errors filter
- Issue plugin commands in admin settings page
- My plugin class doesn’t work! [closed]
- Creating a shortcode, but getting tied up with OOP and Classes?
- Call PHP file within a plugin to activate function
- add_action not calling back to function
- Adding custom fields to WordPress nav menus
- Example Dashboard Widget, Cancel not working
- Woocommerce checkout update totals with datepicker
- add_shortcode() not working inside of function
- How to add and remove a page
- correct way to call javascript into hook function
- “dashboard”-named PHP file doesn’t get included
- How to get plugin activate URL to use URL vars?
- rewrite URL based on selected taxonomy for post page
- Woocommerce – Convert Delivery method into a custom field
- How to Upload Images From a Folder (Not WP_Uploads)
- Possible to get all posts with my shortcode?
- What’s wrong with this post__not_in argument?
- Plugin uninstall function is not working
- Loading custom js file on the admin page through plugin
- How to prevent someone from entering strings without making it available for translation?
- I am unable to save my data from a form
- Check if post belongs to any category
- What’s wrong with my usage of add_filter
- Moving/dragging a metabox removes TinyMCE’s content
- How can I develop a plugin that generates a page dynamically
- Redirect in WordPress plugin
- Converting data-name editor plugin to Gutenberg plugin
- Preventing double loading JS scripts (like React) when developing for Gutenberg
- Can calling wp_enqueue_style in wp_iframe apply the stylesheet to everything not just the iframe?
- Copied files from plugin to theme not working
- How can I allow the user to press enter without creating a new element in the editor?
- wp_ prefix changed. What is the way to change so any prefix is understood?
- Forward an old url rewrite scheme to a new one?
- How to call function from another plugin?
- List categories with descriptions via plugin
- How to exclude “uncategorized” from custom categories widget?
- How to create wordpress media library UI on plugin page
- Why my theme’s css not working on another site
- Override category archive page title (not the head title)
- Using custom IDP with WP
- Trying to run a Ajax request from a checkout form in woocommerce via a custom plugin
- get_queried_object_id combined with wp_redirect gets wrong id
- Using WordPress Boilerplate (WPBP) for WP Multisite Plugin
- WordPress5.2.3: Better File Download Plugin validation issue
- How do I make secure API calls from my WordPress plugin?
- esc_attr() on hard coded string
- Creating a return url for getting data from external api
- WordPress Plugin Boilerplate – add actions and/or filters based on user’s role
- How to handle ajax Request in a complex-structured plugin?
- How to use functions from Woocommerce documentation?
- Is it possible to restore an expired transient?
- Experts opinions needed: How (in)secure is this approach?
- WP API users per page
- action callback, for action dispatched as reported by hook sniffer, not called
- How to use get_pages( ) correctly with ‘child_of’ to replace page with child page
- variable created in page.php is null inside of header.php
- Access WordPress Tag Function From Modal
- Problem with Poedit [closed]
- how can I insert a link on login page
- Insert plugin html content to a specific spot in the frontpage
- Is Explicit Versioning a better alternative to Semantic Versioning for wordpress?
- Help interpreting @wordpress/create-block-tutorial-template usage error
- Leveraging Core Functionality in Icon Upload Plugin [closed]
- WooCommerce adds a newline symbol (\n) between email recipients
- How can I chanage the user for the composer container in wp-env?
- Adding a navigation with wp_nav_menu() to a custom block in the site editor
- Why isn’t custom sidebar panel not showing up in the Gutenberg Editor?
- Ninja Forms: Front-End Forms, Post ID?