{"id":32652,"date":"2011-01-11T11:39:45","date_gmt":"2011-01-11T11:39:45","guid":{"rendered":"https:\/\/ru.wordpress.org\/support\/2011\/01\/11\/%d0%bd%d0%b5-%d0%bc%d0%be%d0%b3%d1%83-%d0%be%d0%bf%d1%80%d0%b5%d0%b4%d0%b5%d0%bb%d0%b8%d1%82%d1%8c-current_user\/"},"modified":"2011-01-11T11:39:45","modified_gmt":"2011-01-11T11:39:45","slug":"%d0%bd%d0%b5-%d0%bc%d0%be%d0%b3%d1%83-%d0%be%d0%bf%d1%80%d0%b5%d0%b4%d0%b5%d0%bb%d0%b8%d1%82%d1%8c-current_user","status":"closed","type":"topic","link":"https:\/\/ru.wordpress.org\/support\/topic\/%d0%bd%d0%b5-%d0%bc%d0%be%d0%b3%d1%83-%d0%be%d0%bf%d1%80%d0%b5%d0%b4%d0%b5%d0%bb%d0%b8%d1%82%d1%8c-current_user\/","title":{"rendered":"\u043d\u0435 \u043c\u043e\u0433\u0443 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c current_user"},"content":{"rendered":"<p>\u042f \u0441\u0434\u0435\u043b\u0430\u043b \u043a\u043d\u043e\u043f\u043a\u0443, \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u043b \u0435\u0435 \u0432\u043d\u0443\u0442\u0440\u0438 \u043f\u043e\u0441\u0442\u0430. \u041a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043a\u043b\u0438\u043a\u0430\u0435\u0442 \u043d\u0430 \u044d\u0442\u0443 \u043a\u043d\u043e\u043f\u043a\u0443, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f ajax-\u0437\u0430\u043f\u0440\u043e\u0441, \u043e\u0431\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0439\u0441\u044f \u043a \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c\u0443 php-\u0444\u0430\u0439\u043b\u0443, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0435\u043c\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u0412\u043d\u0443\u0442\u0440\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441, \u043c\u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c id \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043f\u0440\u0438\u0448\u0435\u043b \u0437\u0430\u043f\u0440\u043e\u0441.<\/p>\n<p>\u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442.<\/p>\n<pre><code>function somefunc(){\nglobal $current_user;\n$userid = $current_user-&gt;ID;\n}<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 $current_user \u0438 $userid \u043f\u0443\u0441\u0442\u044b.<\/p>\n<p>\u0432\u0442\u043e\u0440\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442<\/p>\n<pre><code>function somefunc(){\n$current_user = wp_get_current_user()\n$userid = $current_user-&gt;ID\n}<\/code><\/pre>\n<p>\u0412\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0430: Call to undefined function wp_get_current_user() &#8230;<br \/>\n\u041f\u0440\u043e\u0447\u0438\u0442\u0430\u043b, \u0447\u0442\u043e \u044d\u0442\u0430 \u043e\u0448\u0438\u0431\u043a\u0430 \u0438\u0441\u0447\u0435\u0437\u0430\u0435\u0442 \u0435\u0441\u043b\u0438 \u043f\u043e\u0434\u0433\u0440\u0443\u0437\u0438\u0442\u044c pluggable.php<\/p>\n<p>\u0442\u0440\u0435\u0442\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442<\/p>\n<pre><code>function somefunc(){\n        require_once &quot;wp-includes\/pluggable.php&quot;;\n         $current_user = wp_get_current_user();\n$userid = $current_user-&gt;ID\n}<\/code><\/pre>\n<p>\u0412\u043e\u0437\u043d\u0438\u043a\u0430\u043a\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0430: Call to undefined function do_action() in &lt;b&gt;\\wp-includes\\pluggable.php&lt;\/b&gt; on line &lt;b&gt;533&lt;\/b&gt;<\/p>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044f wp_get_current_user() \u043d\u0430\u0439\u0434\u0435\u043d\u0430, \u043d\u043e \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u0446\u0435\u043f\u043e\u0447\u043a\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u043e\u0448\u0438\u0431\u043a\u0430. \u0412\u0441\u0435 \u044d\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043d\u043e ID \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043f\u043e\u0441\u043b\u0430\u0432\u0448\u0435\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441, \u044f \u0442\u0430\u043a \u0438 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b. \u0423\u0432\u0430\u0436\u0430\u0435\u043c\u044b\u0435 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0441\u0442\u044b &#8212; \u043f\u043e\u043c\u043e\u0433\u0438\u0442\u0435, \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430<\/p>\n","protected":false},"template":"","class_list":["post-32652","topic","type-topic","status-closed","hentry","topic-tag-139","topic-tag-id"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ru.wordpress.org\/support\/wp-json\/wp\/v2\/topic\/32652","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ru.wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/ru.wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/ru.wordpress.org\/support\/wp-json\/wp\/v2\/topic\/32652\/revisions"}],"wp:attachment":[{"href":"https:\/\/ru.wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=32652"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}