{"id":233020,"date":"2023-02-03T09:45:00","date_gmt":"2023-02-03T06:45:00","guid":{"rendered":"https:\/\/wordpress.mediadoma.com\/?p=233020"},"modified":"2023-02-03T09:59:27","modified_gmt":"2023-02-03T06:59:27","slug":"jak-pereviriti-chi-odin-abo-kilka-koristuvachiv-uvijshli-v-sistemu-za-dopomogoju-fajliv-cookie-v-wordpress","status":"publish","type":"post","link":"https:\/\/wordpress.mediadoma.com\/uk\/jak-pereviriti-chi-odin-abo-kilka-koristuvachiv-uvijshli-v-sistemu-za-dopomogoju-fajliv-cookie-v-wordpress\/","title":{"rendered":"\u042f\u043a \u043f\u0435\u0440\u0435\u0432\u0456\u0440\u0438\u0442\u0438, \u0447\u0438 \u043e\u0434\u0438\u043d \u0430\u0431\u043e \u043a\u0456\u043b\u044c\u043a\u0430 \u043a\u043e\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0456\u0432 \u0443\u0432\u0456\u0439\u0448\u043b\u0438 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0437\u0430 \u0434\u043e\u043f\u043e\u043c\u043e\u0433\u043e\u044e \u0444\u0430\u0439\u043b\u0456\u0432 cookie \u0432 WordPress?"},"content":{"rendered":"<p><a href=\"https:\/\/wordpress.mediadoma.com\/uk\/posibnik-iz-plaginiv-wordpress-jak-napisati-pershij-plagin\/\" title=\"WordPress\">WordPress<\/a> \u043d\u0430\u0434\u0430\u0454 API <strong>is_user_logged_in()<\/strong>, \u0449\u043e\u0431 \u043f\u0435\u0440\u0435\u0432\u0456\u0440\u0438\u0442\u0438, \u0447\u0438 \u0432\u0432\u0456\u0439\u0448\u043e\u0432 \u0445\u0442\u043e\u0441\u044c \u0456\u0437 \u043a\u043e\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0456\u0432, \u0430\u043b\u0435, \u043d\u0430 \u0436\u0430\u043b\u044c, \u0432\u0456\u043d \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0438\u0439 \u0431\u0435\u0437\u043f\u043e\u0441\u0435\u0440\u0435\u0434\u043d\u044c\u043e, \u043a\u043e\u043b\u0438 \u0432\u0438 \u043f\u0438\u0448\u0435\u0442\u0435 <a href=\"https:\/\/helloacm.com\/how-to-disable-ftp-login-details-in-wordpress-when-upgrading-plugins\/\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">\u043f\u043b\u0430\u0433\u0456\u043d\u0438<\/a>, \u043d\u0430\u043f\u0440\u0438\u043a\u043b\u0430\u0434, \u043f\u043b\u0430\u0433\u0456\u043d\u0438 \u0437\u0430\u0432\u0430\u043d\u0442\u0430\u0436\u0443\u044e\u0442\u044c\u0441\u044f \u043f\u0435\u0440\u0435\u0434 <strong>pluggable.php<\/strong>, \u0434\u0435 <strong>\u0432\u0438\u0437\u043d\u0430\u0447\u0435\u043d\u043e is_user_logged_in()<\/strong>.<\/p>\n<p>\u0417 \u0440\u0435\u0430\u043b\u0456\u0437\u0430\u0446\u0456\u0457 <strong>is_user_logged_in()<\/strong> \u0432\u0438 \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0431\u0430\u0447\u0438\u0442\u0438, \u0449\u043e \u0446\u0435:<\/p>\n<pre><code>function is_user_logged_in() {\n\u00a0 \u00a0 $user = wp_get_current_user(); \n\u00a0 \u00a0 return $user-&gt;exists();\n}<\/code><\/pre>\n<p>\u041e\u0442\u0436\u0435, \u043c\u0438 \u043c\u043e\u0436\u0435\u043c\u043e \u0437\u043c\u0456\u043d\u0438\u0442\u0438 \u0444\u0443\u043d\u043a\u0446\u0456\u044e, \u0449\u043e\u0431 \u043f\u0435\u0440\u0435\u0432\u0456\u0440\u0438\u0442\u0438, \u0447\u0438 \u0432\u0432\u0456\u0439\u0448\u043e\u0432 \u043f\u0435\u0432\u043d\u0438\u0439 \u043a\u043e\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447.<\/p>\n<pre><code>function is_username_logged_in($username) {\n\u00a0 \u00a0 $user = wp_get_current_user(); \n\u00a0 \u00a0 return $user-&gt;user_login == $username; \u00a0\n}<\/code><\/pre>\n<p>\u041e\u0434\u043d\u0430\u043a \u043e\u0441\u043d\u043e\u0432\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0456\u044f <strong>wp_get_current_user<\/strong> \u0432\u0441\u0435 \u0449\u0435 \u0432\u0438\u0437\u043d\u0430\u0447\u0435\u043d\u0430 \u0443 <strong>pluggable.php<\/strong>. \u0414\u0430\u043b\u0456 \u0440\u0435\u0430\u043b\u0456\u0437\u043e\u0432\u0430\u043d\u043e \u0444\u0443\u043d\u043a\u0446\u0456\u044e, \u044f\u043a\u0430 \u043f\u0440\u0438\u0439\u043c\u0430\u0454 \u043c\u0430\u0441\u0438\u0432 \u0434\u043e\u0437\u0432\u043e\u043b\u0435\u043d\u0438\u0445 \u0456\u043c\u0435\u043d \u043a\u043e\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0456\u0432 \u0456 \u043f\u043e\u0432\u0435\u0440\u0442\u0430\u0454 \u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044f true, \u044f\u043a\u0449\u043e \u0431\u0443\u0434\u044c-\u044f\u043a\u0438\u0439 \u0434\u043e\u0437\u0432\u043e\u043b\u0435\u043d\u0438\u0439 \u043a\u043e\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447 \u0443\u0432\u0456\u0439\u0448\u043e\u0432 \u0443 \u0441\u0438\u0441\u0442\u0435\u043c\u0443.<\/p>\n<pre><code>function allowedUsersLoggedIn($allowd_users) {\n\u00a0 \u00a0 if (count($_COOKIE)) {\n\u00a0 \u00a0 \u00a0 \u00a0 foreach ($_COOKIE as $key =&gt; $val) {\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 if (substr($key, 0, 19) === \"wordpress_logged_in\") {\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 if (preg_match('\/^('. implode('|', $allowed_users). ')\/', $val, $matches)) {\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 return true;\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 }\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 }\n\u00a0 \u00a0 \u00a0 \u00a0 }\n\u00a0 \u00a0 }\n\u00a0 \u00a0 return false;\n}<\/code><\/pre>\n<p>\u0412\u0438 \u043c\u043e\u0436\u0435\u0442\u0435 \u0431\u0435\u0437\u043f\u0435\u0447\u043d\u043e \u0432\u0438\u043a\u043e\u0440\u0438\u0441\u0442\u043e\u0432\u0443\u0432\u0430\u0442\u0438 \u0446\u044e \u0444\u0443\u043d\u043a\u0446\u0456\u044e \u0431\u0443\u0434\u044c-\u0434\u0435, \u043d\u0430\u0432\u0456\u0442\u044c \u0431\u0435\u0437 \u0441\u0435\u0440\u0435\u0434\u043e\u0432\u0438\u0449\u0430 WP. \u0417\u0440\u0430\u0437\u043e\u043a \u0432\u0438\u043a\u043e\u0440\u0438\u0441\u0442\u0430\u043d\u043d\u044f \u0431\u0443\u0434\u0435:<\/p>\n<pre><code>if (allowedUsersLoggedIn(array(\"helloacm\", \"steakovercooked\")) {\n\u00a0 \/\/ code that only allowed users run\n}<\/code><\/pre>\n<p>\u041f\u0440\u0438\u043d\u0446\u0438\u043f \u0446\u0456\u0454\u0457 \u0444\u0443\u043d\u043a\u0446\u0456\u0457 \u043f\u043e\u043b\u044f\u0433\u0430\u0454 \u0443 \u043f\u0435\u0440\u0435\u0432\u0456\u0440\u0446\u0456 \u0444\u0430\u0439\u043b\u0443 COOKIE \u043d\u0430 \u043d\u0430\u044f\u0432\u043d\u0456\u0441\u0442\u044c \u0437\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043e\u0433\u043e \u0440\u044f\u0434\u043a\u0430, \u043a\u043e\u043b\u0438 \u0434\u043e\u0437\u0432\u043e\u043b\u0435\u043d\u0456 \u043a\u043e\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0456 \u0432\u0432\u0456\u0439\u0448\u043b\u0438 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0443.<\/p>\n<p><div id=\"PostUnique_PostSource\" style=\"padding-top: 50px\">\u0414\u0436\u0435\u0440\u0435\u043b\u043e \u0437\u0430\u043f\u0438\u0441\u0443:  <a target=\"_blank\" rel=\"noopener nofollow\" href=\"\/\/helloacm.com\" class=\"external external_icon\">helloacm.com<\/a><\/div><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u042f\u043a \u043f\u0435\u0440\u0435\u0432\u0456\u0440\u0438\u0442\u0438, \u0447\u0438 \u043e\u0434\u0438\u043d \u0430\u0431\u043e \u043a\u0456\u043b\u044c\u043a\u0430 \u043a\u043e\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0456\u0432 \u0443\u0432\u0456\u0439\u0448\u043b\u0438 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0437\u0430 \u0434\u043e\u043f\u043e\u043c\u043e\u0433\u043e\u044e \u0444\u0430\u0439\u043b\u0456\u0432 cookie \u0432 WordPress?<\/p>\n","protected":false},"author":1,"featured_media":224779,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_wp_rev_ctl_limit":""},"categories":[808,869,839,902,849,725],"tags":[1174],"class_list":["post-233020","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php-10","category-wordpress-10","category-kerivnytstvo-dlia-pochatkivtsiv","category-kod-3","category-pidruchnyky","category-rozrobnyk","tag-affiai-uk"],"_links":{"self":[{"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/posts\/233020","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/comments?post=233020"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/posts\/233020\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/media\/224779"}],"wp:attachment":[{"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/media?parent=233020"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/categories?post=233020"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/tags?post=233020"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}