-
AuthorPosts
-
February 20, 2019 at 4:42 pm #1069530
I am trying to redirect users after they either login or create an account on the /my-account/ page and none of the methods or plugins I’ve found have worked. Or I have just simply configured things wrong.
revestmanagement.com
Thanks,
AdamFebruary 20, 2019 at 5:16 pm #1069546Hey adamghart,
Can you give us steps on the procedure you’ve done to do the redirection?
When I logged in to your site, I was redirected to this page (link in private content).
It seems to be working, maybe not the right page.Best regards,
NikkoFebruary 20, 2019 at 5:29 pm #1069557It redirects when you log in using the admin login, but not on the front end when customers either register or sign in on the /my-account/ page https://www.revestmanagement.com/my-account/ . The page you got redirected to is where I want customers to be redirected to after login or registration.
February 21, 2019 at 2:03 pm #1069944Hi adamghart,
I see, I think that’s because you’re logging in via woocommerce login, try adding this php code in functions.php:
add_filter('woocommerce_login_redirect', 'wc_login_redirect'); function wc_login_redirect( $redirect_to ) { $redirect_to = 'https://www.revestmanagement.com/product/rent/'; return $redirect_to; }
Best regards,
NikkoNovember 8, 2020 at 3:35 pm #1259119Hello,
I want to have a redirect after registration on this site: https://yuppie.bg/wp-login.php?action=register to this page: https://yuppie.bg/moyat-profil/Please help us to resolve this issue.
Thanks!!!
November 9, 2020 at 5:35 am #1259172Hi Cherryadvertising,
Can you try to follow the instructions on this tutorial: https://www.wpbeginner.com/plugins/how-to-redirect-users-after-successful-login-in-wordpress/
Hope it helps.Best regards,
NikkoNovember 11, 2020 at 12:00 pm #1259840Hi Nikko,
Another question, how can I add a role field to the registration form: https://yuppie.bg/wp-login.php?action=register
То can users choose one of the two or more roles shown.Thanks!!!
Best regards
November 11, 2020 at 1:15 pm #1259868Hi Cherryadvertising,
I would suggest using membership plugins for this feature (or maybe some third party plugins that allows this feature).
If you know how to code then, this one might help: https://wordpress.stackexchange.com/questions/195603/how-to-add-users-roles-dropdown-in-registration-in-wordpressBest regards,
NikkoNovember 21, 2020 at 6:12 pm #1261978Hi Niko,
about role field to the registration form.
Your suggestion with a code helped us.
Thanks a lot!
Is it possible to direct us to a solution with a code and for: a redirect after registration on this site: https://yuppie.bg/wp-login.php?action=register to this page: https://yuppie.bg/moyat-profil/Best regards,
AnnaNovember 22, 2020 at 4:45 pm #1262121Hi @Niko,,
I’m in a hurry to write that we have resolved the issue with the redirect. :-)
About the code to add a role field to the registration form we tested this:
//1. Add a new form element…
add_action( ‘register_form’, ‘yuppiegame_register_form’ );
function yuppiegame_register_form() {global $wp_roles;
echo ‘<label for=”role”>Избери роля</label>’;
echo ‘<select id=”role” name=”role” class=”input”>’;
foreach ( $wp_roles->roles as $key=>$value ) {
// Exclude default roles such as administrator etc. Add your own
if ( ! in_array( $value[‘name’], [ ‘Administrator’, ‘Contributor’, ‘Editor’,
‘Author’, ‘Bookly Supervisor’, ‘Bookly Administrator’, ‘Campaign Manager’,
‘Donor’, ‘Orehhero’, ‘TLGSofia’, ‘SEO Manager’, ‘SEO Editor’,
‘Shop manager’, ‘Translator’, ] )) {
echo ‘<option value=”‘.$key.'”>’.$value[‘name’].'</option>’;
}
}
echo ‘</select>’;
}//2. Add validation.
add_filter( ‘registration_errors’, ‘yuppiegame_registration_errors’, 10, 3 );
function yuppiegame_registration_errors( $errors, $sanitized_user_login, $user_email ) {if ( empty( $_POST[‘role’] ) || ! empty( $_POST[‘role’] ) && trim( $_POST[‘role’] ) == ” ) {
$errors->add( ‘role_error’, __( ‘ERROR: You must include a role.’, ‘mydomain’ ) );
}return $errors;
}//3. Finally, save our extra registration user meta.
add_action( ‘user_register’, ‘yuppiegame_user_register’ );
function yuppiegame_user_register( $user_id ) {$user_id = wp_update_user( array( ‘ID’ => $user_id, ‘role’ => $_POST[‘role’] ) );
}The code works, adds the role in the admin panel, but there is a problem with the link to change the password, which the user receives after registering his e-mail.
By clicking on the link we receive a message: the password change link is invalid. Please request a password reset …. ie. adds another step. Which extends the path of the user!We recently updated the topic from 4.4.1 to the latest version. Could this be the reason?
I ask for your assistance.
Thanks!
Anna
- This reply was modified 3 years, 12 months ago by Cherryadvertising.
November 23, 2020 at 5:55 am #1262248Hi Anna,
Is it possible to direct us to a solution with a code and for: a redirect after registration on this site: https://yuppie.bg/wp-login.php?action=register to this page: https://yuppie.bg/moyat-profil/
The only hook I could find that should help with this is https://codex.wordpress.org/Plugin_API/Filter_Reference/registration_redirect (without a plugin). The documentation also shows an example on how to use it.We recently updated the topic from 4.4.1 to the latest version. Could this be the reason?
You can try to test it with the default WordPress theme to know if Enfold may be interfering with the process, but as far as I know, Enfold does not interfere with it.Best regards,
Nikko -
AuthorPosts
- You must be logged in to reply to this topic.