You call this function too early, before pluggable function is_user_logged_in()
is defined. Try this:
function wpse_get_current_user() {
$current_user = wp_get_current_user();
// do other stuff here
}
add_action( 'init', 'wpse_get_current_user', 10 );
Related Posts:
- How do I make a redirect in PHP?
- WordPress and event-driven programming – what is it about?
- How WordPress encrypt password? [duplicate]
- Retrieve POST data from AJAX call
- Adding a custom image upload size and making it selected by default?
- How to include external page to wordpress page?
- Facebook Comment Count
- Conditionally loading JavaScript based on the Advanced Custom Fields in the post
- How to overwrite youtube embed?
- How to resize image on client-side before upload?
- Filter the blog title displayed in the header
- Limit the Excerpt field in WP-Admin in words
- Print html when custom field has value inside while loop
- Foreach insert query the best way
- Generating add_settings_section() calls dynamically
- How to change / delete product short description in Woocommerce
- How to generate page content from database the right way?
- How do I show the featured images for my child pages on my parent pages?
- Register non hierarchical taxonomy and the show meta box in the post type
- Admin username and password
- dynamic php inside wordpress page
- Converting MYSQL to WordPress $WPDB
- WP_Query loop, does not display special characters in title correctly
- Random Default Avatar Function
- Get Admin Email Address From External PHP page
- Redirect to another page after submission using wp_mail
- How do I get current page ID in WordPress customizer file?
- How to run a php file that uses wordpress functions from command line?
- Loop with slider (slider not loading)
- wordpress media library new uploads don’t write to database
- Add data attribute to each li in menu
- Was told to change the .htacess file form .html to .php so this would work properly
- WordPress Ignoring .user.ini
- Cron events are disappearing, or cannot be updated in WordPress
- Prev/Next child navigation for current page modifications?
- How to bypass maintenance mode with external cron?
- Displaying Woocommerce Product Category in WordPress
- Split reads to a different connection string
- custom user role wordpress – grant guest access to edit.php without insert/update/delete
- PHP > Scheduled Tasks > Sending daily email with dynamic API variables
- HTML escaping data with ajax requests
- Metabox Not saving data
- 2nd page displaying the exact same posts as my first page (minus the very first post)
- Timthumb.php image gallery not working on Multisite WordPress
- Why doesn’t PhotoSmash plugin play well with wp_query?
- Parse error: syntax error, unexpected ‘,’
- Use get() method to grab all categories and output inside another method
- get_the_ID() doesnt work
- How can I split my query result in 2 arrays?
- How do I check if there is a tag in the title
- GravityForms Limit Submission Per Time Period by User or IP by 30 minutes?
- php loading different structure than source code
- Truncate title to single line & container width
- Submit form to db
- WordPress Rewrite Rule
- How do I attach an invoice PDF to an email in the Dukapress plugin for WordPress?
- Programmatically revert to backup .htaccess a possibility?
- Prevent post from being published and show error
- how to get wordpress page url php code [duplicate]
- WordPress User Meta value variable into Google Gauge Chart
- Problems updating nested ACF field groups
- how to pull all usernames from a custom user role, then do some array modification
- Unable to delete related media attachments with deleted post
- Submiting with problems on one of the options php wprdpress
- Embed video from streamtape using direct link
- separate list of programs in html/javascript coming from php
- Is there a PHP function that will return the block ID generated by WordPress?
- retrieve “Link Color” value
- Woocommerce checkout page – custom field checkbox value into email
- How to print all the inline styles in the WP_Styles instance together with their keys?
- Issues adding Recaptcha v3 to WordPress Registration
- Create form which redirects to site in network?
- Theme editing “post thumbnail” help
- Hide comment notification number and buttons in wp backend
- Create html tree sitemap
- Restrict File Type Uploads by User on Wordress via functions.php
- How to Request a User to Register on Landing at a Site, Then Automatically Delete the Users Password on Logout?
- meta field for numerous links
- Custom HTML form using PHP – help with ajax/username validation
- WordPress AJAX load post metadata in modal
- Add point on excerpt post
- Custom Theme, Editor won’t wrap text (i.e. change width)
- Where can I find the declaration of `$_wp_theme_features`?
- add shortcode heading showing multiple time
- How I can add div to menu?
- How to print redirected query string variables to the page?
- Limit ads appearing more than three times
- Multiple URL from Custom post name
- Admin-area broken through weird issues
- Display a query with multiple post types and same relationship on a single page
- Get string from array and start loop [closed]
- Custom query_posts() parameter
- Convert ACF checkbox choices to links [closed]
- How to modify this function to exclude also the post belonging to a specific category?
- wp_link_pages return value even when is condition inside if statement
- How to add Paragraph Tags in WordPress using Visual Composer?
- PHP – Multiple variables in insert post array
- advanced custom fields: repeater field within conditional statement [closed]
- Search custom post type posts only by meta fields?
- How to pass value to add_filter wpcf7_form_tag from another function?