Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #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,
    Adam

    #1069546

    Hey 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,
    Nikko

    #1069557

    It 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.

    #1069944

    Hi 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,
    Nikko

    #1259119

    Hello,
    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!!!

    #1259172

    Hi 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,
    Nikko

    #1259840

    Hi 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

    #1259868

    Hi 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-wordpress

    Best regards,
    Nikko

    #1261978

    Hi 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,
    Anna

    #1262121

    Hi @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

    #1262248

    Hi 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

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.