What is the point of Thrower's Bandolier? 2010, 18:57 Function Reference/wp get current user Languages: English ( Add your language) This page was moved to https://developer.wordpress.org/reference/functions/wp_get_current_user/ except above language locator. There are basically two options. It only takes a minute to sign up. Making statements based on opinion; back them up with references or personal experience. The action set_current_user is called within wp_set_current_user after current_user is set. The current user will be set to the logged-in person. Where does this (supposedly) Gibson quote come from? http://www.example.com/wordpress/test.php. wp_update_user () WP 2.0.0 Update a user data in the database. Is there a way to identify a user in a custom REST API method? Hence the undefined function error. I have seen two issues which I think have the same fundamental cause. The best answers are voted up and rise to the top, Not the answer you're looking for? get_post_field retrieves data from a post field based on the current or defined post ID allowing us to get current page name WordPress. And you should not try to include() this file directly. You can return to the previous directory afterwards by storing the get_cwd() first. Learn more about Stack Overflow the company, and our products. I have been troubleshooting an issue where we use the Restrict Content Pro plugin to try and restrict access to documents created by WP Document Revisions. Browse other questions tagged. Everything is going well except calling the wp_get_current_user() function in the get_items() function return empty user even though the user is logged in in the website. An alternative option is to use the following command to download the latest version of WordPress: wget https://wordpress.org/latest.zip Is there a proper earth ground point in this switch box? What is the point of Thrower's Bandolier? ERROR: CREATE MATERIALIZED VIEW WITH DATA cannot be executed from a function, About an argument in Famine, Affluence and Morality. Asking for help, clarification, or responding to other answers. File: wp-includes/user.php. WP Document Revisions Frequently Asked Questions Support Threads Active Topics Than we use the wp_get_current_user to return the WP_User object of the current user. I have a wordpress installation, lets say for arguments sake it's installed to http://www.example.com/wordpress. The current user will be set to the logged-in person. It only takes a minute to sign up. I need to add current users id in the embedded link so that webpage knows how many individual users from my website is seeing their embedded pages. Go to Users > All users. Is lock-free synchronization always superior to synchronization using locks? The call to wp_get_current_user() returns the WP_User object. I was under the impression it did something like load a file - in my case pluggable.php - really all I need is just $current_user->user_login. Start here for a quick overview of the site, Detailed answers to any questions you might have, Discuss the workings and policies of this site. The API uses nonces with the action set to wp_rest. Handles Ajax requests for community events. - fusion3k Apr 8, 2016 at 11:05 Checks if the current user belong to a given site. Why are physically impossible and logically impossible concepts considered separate in terms of probability? How can I call a function from one plugin within another plugin? I can give you an alternative solution that may or may not work in your case (since I don't fully understand your case): Usually we attach it to the JS to run AJAX calls: wp_localize_script( 'THE_JS_THAT WAS_ENQUEUED', 'PARAMS', array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) ); Even without wp_localize_script you can always print the admin_url( 'admin-ajax.php' ) to screen, and input it in any other process. For example, even though I am logged into the site on which I am attempting to display the document, the wp_get_current_user() call comes back with a user with ID 0. add_meta_box ( $id, $title, $callback, $post_type, $context, $priority, $callback_args ); We're using the meta boxes to add the form fields, along with a wp_nonce_field for security. Turned out it was this point, I didnt wait till plugins loaded. Use chdir() to move into WordPress root before including and even calling anything related to WordPress. It doesn't matter about the location as I am only running it/this as a test at the moment, once I know it works I will be adding it into a plugin which already has the. This might not be a concern for small applications of the function, but personally in my experience I have a system where I needed the current user id multiple times and it slowed down the site by a lot as the user table was also large. I was insterting my script in html