Skip to content

Instantly share code, notes, and snippets.

@AmrutHandral
Last active February 19, 2017 09:40
Show Gist options
  • Select an option

  • Save AmrutHandral/e22f11915a64d77309b7d9eab17e5913 to your computer and use it in GitHub Desktop.

Select an option

Save AmrutHandral/e22f11915a64d77309b7d9eab17e5913 to your computer and use it in GitHub Desktop.
-------------------------------------------------------------------------------------------------------------------------------
------------------------------- SQL to create new admin user for WordPress site ---------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------
INSERT INTO `wp_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_status`)
VALUES ('username', MD5('password'), 'firstname lastname', 'email@example.com', '0');
INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`)
VALUES (NULL, (Select max(id) FROM wp_users), 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');
INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`)
VALUES (NULL, (Select max(id) FROM wp_users), 'wp_user_level', '10');
Replace the username and password.
--------------------------------------------------------------------------------------------------------------------------------
----------------------------- Error while uploading the mp3 and many more in media library -----------------------------------
--------------------------------------------------------------------------------------------------------------------------------
define('ALLOW_UNFILTERED_UPLOADS', true);
You can add the above line of code in the wp-config.php file just above the following statement.
Help link: http://freewptp.com/fix-wordpress-issue-sorry-this-file-type-is-not-permitted-for-security-reasons/
Also add the add Mime type in .htaccess: http://www.htaccess-guide.com/adding-mime-types/
---------------------------------------------------------------------------------------------------------------------------------
------------------------------------------ php mail function with error message -----------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------
<?php
$to = "host1947@gmail.com";
$subject = "Testing php mail";
$body = "Hello,\n\nchecking php mail functionality";
"X-Mailer: php";
if (mail($to, $subject, $body)) {
echo("<p>Message sent!</p>");
} else {
echo("<p>Message delivery failed...</p>");
}
?>
---------------------------------------------------------------------------------------------------------------------------------------
------------------------------ SQL query execution to update the wp_users table with new password -----------------------------------
---------------------------------------------------------------------------------------------------------------------------------------
1. Login to phpMyadmin
2. select the database
3. click on wp-user
4. Run the sql querry
UPDATE `wp_users` SET `user_pass`= MD5('yourpassword') WHERE `user_login`='yourusername';
5. Click go, that's it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment