After registration

Home Forums Legacy Support Support queries Setup issues After registration

Viewing 15 posts - 1 through 15 (of 17 total)
  • Author
    Posts
  • #230507
    MeesterGijs
    Spectator
    Hello, Once my visitors are registered they have to pay for their membership. But if they stop after registration they can login but they can't access courses. But once logged in you still see the register button at the homepage (here) and here in the footer. Is it possible to redirect a url (meestergijs.nl/aanmelden) to meestergijs.nl/winkel for logged in visitors? Also, I thought I could use this code to change the label Add to Cart. But it does nothing. Could you help with that as well? /* Aangepaste tekst voor toevoegen aan winkelmand */ add_filter( 'woocommerce_product_single_add_to_cart_text', 'lw_cart_btn_text' ); add_filter( 'woocommerce_product_add_to_cart_text', 'lw_cart_btn_text' ); //Changing Add to Cart text to Buy Now! function lw_cart_btn_text() { return __( 'Buy Now!', 'woocommerce' ); } Thanks, Gijs
    #230552
    logan
    Member
    hello, use this code in customizer, once user is logged in he will be redirected to the entered url automatically. add_filter('login_redirect','logan_custom_login_redirection',999,3); function logan_custom_login_redirection($redirect_url,$request_url,$user){ $url = 'http://google.com'; return $url; }
    #230558
    MeesterGijs
    Spectator
    But I don't want paid members that login to get redirected to the shop. How can we get a redirect not from loggin in but from having paid/finished the checkout page?
    #230649
    Anshuman Sahu
    Keymaster
    To change the add to cart label you can actually translate it using loco translate .   To redirect based on if user bought any product use this code :   add_filter('login_redirect','logan_custom_login_redirection',999,3);   function logan_custom_login_redirection($redirect_url,$request_url,$user){   $bought = false;     // Get all customer orders $customer_orders = get_posts( array( 'numberposts' => -1, 'meta_key'    => '_customer_user', 'meta_value'  => $user->ID, 'post_type'   => 'shop_order', // WC orders post type 'post_status' => 'wc-completed' // Only orders with status "completed" ) );   if(!empty($customer_orders) && count($customer_orders)){ //already bought to wherever you want $url = 'https://meestergijs.nl/start/'; }else{ //to shop $url = 'https://meestergijs.nl/winkel/'; }     return $url;   }
    #230689
    MeesterGijs
    Spectator
    Alex, Thanks for the code. This is what I eventually will need to use when I have more than one product.. But can I also so send registered users automatically to checkout with my only product available in their basket? See this image; Explain what you see: Users now follow black arrows. You deleted the purple box for me. But I want to go like the red arrow..
    #230757
    logan
    Member
    use this code to redirect them directly to the checkout page: add_filter('login_redirect','logan_custom_login_redirection',999,3); function logan_custom_login_redirection($redirect_url,$request_url,$user){ $bought = false; // Get all customer orders $customer_orders = get_posts( array( 'numberposts' => -1, 'meta_key'    => '_customer_user', 'meta_value'  => $user->ID, 'post_type'   => 'shop_order', // WC orders post type 'post_status' => 'wc-completed' // Only orders with status "completed" ) ); if(!empty($customer_orders) && count($customer_orders)){ //already bought to wherever you want $url = 'https://meestergijs.nl/start/';   }else{ //to shop $url = 'https://meestergijs.nl/checkout/'; } return $url; }
    #230773
    MeesterGijs
    Spectator
    The code doesn't work. Is there something in the code I need to change?
    #230879
    MeesterGijs
    Spectator
    The code gave a page not found error when logging in...
    #231007
    logan
    Member
    Please remove the above codes then share the exact url then i will rewrite the codes.
    #231016
    MeesterGijs
    Spectator
    I deleted the code. I want them to register at meestergijs.nl/aanmelden. Then when they click the button AANMELDEN (register) at the bottom of the page, they get logged in and I want them immediately be redirected to checkout with the product in cart (product url: meestergijs.nl/product/abonnement). Checkout url is: meestergijs.nl/checkout. Is this what you mean? Gijs
    #231223
    Anshuman Sahu
    Keymaster
    Well then you can simply enable "login and register simultaneously" settings in the custom registration form. and on a common wordpress hook : " wp_login " you can add your product to cart and redirect to checkout . for which the code is this : add_action('wp_login',function ($username){   global $woocommerce; $checkout_url = $woocommerce->cart->get_checkout_url();                //check if product already in cart   if ( WC()->cart->get_cart_contents_count() == 0 ) {       // if no products in cart, add it   WC()->cart->add_to_cart( $product_id );                }   wp_redirect($checkout_url);exit(); },1);
    #231240
    MeesterGijs
    Spectator
    This is what happened after I added the code: video
    #231299
    Diana
    Participant
    This reply has been marked as private.
    #231302
    MeesterGijs
    Spectator
    Hello, I see. Now it redirects after login. It should redirect after registration (meestergijs.nl/aanmelden). I that possible? When I already have a membership and I log in, I don't need to go to checkout. Hope you understand, Gijs
    #231305
    Anshuman Sahu
    Keymaster
    Sorry please remove the previous code and add this one : add_action('wp_login',function ($username){           //check if product already in cart $product_id = 45;//change the product id here   if ( WC()->cart->get_cart_contents_count() == 0 ) {       // if no products in cart, add it   WC()->cart->add_to_cart( $product_id );                }   },1);   add_filter('wplms_registeration_redirect_url',function($url){   global $woocommerce;   $checkout_url = $woocommerce->cart->get_checkout_url();   return $checkout_url; });       change the product id in above code.
Viewing 15 posts - 1 through 15 (of 17 total)
  • The topic ‘After registration’ is closed to new replies.