Skip to content

Instantly share code, notes, and snippets.

View yawalkar's full-sized avatar
🏠
Working from home

Nitin Yawalkar yawalkar

🏠
Working from home
View GitHub Profile
@yawalkar
yawalkar / new-user.php
Created March 15, 2016 17:33
Create New Admin User if you forgot username and password of admin user. You need to have cpanel / FTP access of your site.
<?php
/*
* Create Admin User
*/
$wp_password = 'PASSWORD'; #enter your desired password here, if you don't line 16 makes sure nothing bad happens like setting you actual password to 'PASSWORD'
$wp_username = 'new-admin';
$wp_email = 'email@domain.com';
if ( $wp_password === 'PASSWORD' )
@yawalkar
yawalkar / woocommerce-login-logout-cart-handling.php
Last active November 20, 2022 13:23
WooCommerce - Login / Logout Cart Handling and redirects
<?php
/**
* Redirect users to custom URL based on their role after login and restore the cart
*
* @param string $redirect
* @param object $user
* @return string
*/
function wp_custom_user_redirect( $redirect, $user ) {
// Get the first of all the roles assigned to the user