How to create new wordpress admin user from FTP - sql

I haven't logged into the wordpress backend of my website in a couple years.
Now, however, none of the passwords I use seem to work. I request a reset, but I NEVER get the email.
I went into PHPMyadmin to change the password of the user, but that doesn't seem to work. The site is still not accepting the new password. I created a new user from phpMyAdmin and that user is still not recognized. So I'm not sure the database I'm updating is the correct database, however it's the only one available. Have I been hacked? I don't understand how none of my passwords are working, I am not receiving lost password emails nor are any of my new users or changed passwords from the phpMyAdmin being recognized.

https://wordpress.org/support/article/resetting-your-password/
Login to your site via FTP and download your active theme's functions.php file.
Edit the file and add this code to it, right at the beginning, after the first
wp_set_password( 'password', 1 );
Put in your own new password for the main admin user. The "1" is the user ID number in the wp_users table.
Upload the modified file back to your site.
After you then are able to login, make sure to go back and remove that code. It will reset your password on every page load until you do.

Just in case you don't have access to database and don't have the user id, use the below code in your active theme's function.php:
Refer here for more options: You can use | ID | slug | email | login
$user = get_user_by( 'email', 'user#example.com' );
$id = $user->ID;
$password = 'your_new_password'; // Plain text password
wp_set_password( $password, $user_id );
Now the new password is: your_new_password.
Make sure to remove the code after your site is loaded once. You won't be able to login without removing this code as it will reset the password everytime page loads.

Related

how do I forget the last user using facebook js sdk

When I use FB.logout() the user gets logged out fine, but then the next time I do FB.login() it logs in the last user without the option to enter in new credentials. I can't find any information on how to forget the previously signed on user. Is there a parameter I can pass into logout or login that would forget the previous user?
I found out that the behavior I wanted could be achieved by deleting the users permissions with the following snippet before logging the user out.
FB.api(`/${fbUserId}/permissions`,
'delete',
{access_token: fbUserAccessToken})

password invalid for customer created during checkout

I'm on a CE 1.9.3.1 with SUPEE 9652.
The password sent in the new account confirmation is blank.
Moreover, if the customer attempts to login, the error message "Invalid login or password" is displayed.
I tried what's suggested here: customer's password not displayed in email templates magento 1.9.1.0
The modification of AccountController.php didn’t helped.
However, commenting
$this->setData('password', null);
in Mage\Customer\Model\Customer.php
solved half of the problem, as customer created with the "register" form receive the password and can login, but not the one registered during checkout.
The "check out created customer" lands in “My account” after the purchase but can't log again once logged-off (until he sets a new password with forgot password button).
I thought it was relative to my theme, so I deleted all files in: /app/design/forontend/my_theme_package/my_theme_name/template But I'm still facing the same issue.
I think that the password set during checkout is somehow wrongly stored.
Any suggestions?
Got it, it was a strange issue ans I don't know where the error's coming from... The answer's here:
https://stackoverflow.com/a/42474835/7553582

How to manually create reset password token using devise

I am developing a Rails 3.2 app. When a user signs up or when I create a user account in my admin panel, a welcome email is sent to them. I want to include a link on which the user can click to get to the password reset page (where they can set/change their password).
So what I want to do basically is to manually create a reset password token, create a link to the reset password page (where they select a new password) and include it in the welcome email. I do not want to send two emails (welcome and reset password).
I guess some of this code could be used but I do not know how.
https://github.com/plataformatec/devise/blob/master/lib/devise/models/recoverable.rb
How can I do this?
Thankful for all help!
Just had to do something similar to this and thought I'd post an answer if someone stumbles on this. Assuming you have devise correctly set up, all you need to do is make sure the user exists in the database and then redirect to the devise route. I leveraged their code here: goo.gl/cE5USm.
def password_reset_controller
user = User.find_by_email( params[:email] )
if user
redirect_to password_path(:user, email: user.email)
else
# do something different
end
end
In console if you call password_path(:user, email: user.email) -> "/users/password?email='email'"
Edit:
Alternatively, you can just use user.send_reset_password_instructions from goo.gl/aPQ8MU

How to avoid popup in http request

I have a url. when i access this through browser a popup comes and ask for user name and password and by giving right credential it opens the page. I want to know how to avoid the popup by passing the user name and password url itself and how to do that
note my username contains # symbol
Thanks A Lot
You can use the form:
http://<user>:<pass>#<host>:<port>/<path>
It even works with # in the username (IE might not support this).

Redirect After Registration in Drupal

Any one know how to go back to the "last page" after a user is presented the login screen and chooses to create a new account?
Basically the sequence is this:
User tries to get to protected content
Redirected to login page
If he logs in he is redirected to original page
If he chooses "create new account" and fills it out, he is redirected to the home page
How do we get him automatically redirected to the original page (not a static page).
There are several ways to go about this. The most straight-forward is to have a login link somewhere in the navigation that appends the destination to the url. The code for this is something like:
<?php
if (user_is_anonymous()) {
$link = l(t('Login'), 'user/login', array('query' => drupal_get_destination()));
}
?>
You can also set a custom access denied page at admin/settings/error-reporting that could either go to a callback that outputs the above code, or to a simple php node that outputs that code.
Additionally, the user login block provided with Drupal core uses the same method to redirect a successful login back to the originating page.
Edit: Note that the above methods will rarely work for registration, because there are more steps involved there. Specifically, when a user needs to verify an email address, passing the originating destination along via the email would involve modifying the core user registration process.
It will potentially still work on a site configured to not verify email addresses. The idea then would be to provide 2 links: 1 for login and the other for registration, both passing along destination information.
LoginToboggan may also be worth pursuing, although it doesn't yet offer the exact registration feature you're looking for.
straight php would be to include a header of this form:
<?php header("Location: " . $_SERVER['HTTP_REFERER']); ?>
for more information refer to the php manual
EDIT:
you can also include a hidden field in your form and set it to
$url = $_SERVER['PHP_SELF']; // or HTTP_REFERER depending on the setup
include the header code snipped to your registration form.