Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #894248

    ottobono
    Participant

    Hi, I would like to split account and register page in woocommerce. How to do it?

    I have another question. I want to display the “Login” page (after the split or to point to the page http://www.mysiteurl.it/wp-login) if user is not logged in and to display my account page and all pages which are under it if logged in:

    Mio account (My account)
    — Modifica account (Edit account)
    — Modifica indirizzo (Edit address)
    — Logout

    Consequently the login page must be hidden until the customer logouts.

    I read in google in some posts that you can and there is some code provided (php code and such), but I cannot understand really good how to do it 🙁 Can you please point me in the right direction? Thank you!

    #894936

    ottobono
    Participant

    I tried this code to show/hide pages:

    
    add_action('wp_head','jg_user_nav_visibility');
    function jg_user_nav_visibility() {
    
        if ( is_user_logged_in() ) {
            $output=" .nav-login { display: none !important; } ";
        } else {
            $output=" .nav-account { display: none !important; } ";
        }
    
        echo $output !important;
    }

    I added “nav-login” class to my login page and “nav-account” to my account page and did not work 🙁

    #895039

    Paul R
    Moderator

    Hi,

    Please remove the code you added in your functions.php file.

    Then add this in custom > edit global css in the customizer

    
    .logged-in .nav-login {
         display:none;
    }
    
    .nav-account {
        display:none;
    }
    
    .logged-in .nav-account {
         display:block !important;
    }
    
    

    Hope that helps.

    #895057

    ottobono
    Participant

    It worked like a charm, thank you!

    Now, how to split registration and login page?

    I found this here: http://stackoverflow.com/questions/23821488/separate-registration-page-in-woo-commerce-website

    edit your form-login.php file and seperate the login form and registration form in two different sections say section A and B.

    now check for a GET parameter in the page which will define which section to show. By default login will be shown, if parameter is found and is “register”, show registration section

    if( isset( $_GET['action']) && $_GET['action'] == "register"){
        // Section for registration
    }else {
        // Section for Login form
    }
    

    you can provide a link for registration as

    <a href="' .get_permalink(woocommerce_get_page_id('myaccount')). '?action=register"> register </a></blockquote>
    

    and this one here: https://www.tmdhosting.com/kb/question/how-to-create-separate-log-in-and-registration-pages-in-woocommerce/

    You can create a copy of the Woocommerce form-login.php and name it form-register.php. The form-login.php is located in /woocommerce/templates/myaccount/ folder.

    Then in the form-login.php you can create a link to the form-register.php using this code:

    <a href="' .get_permalink(woocommerce_get_page_id('myaccount')). '?action=register"> register </a>

    Next you need to modify your themes function.php file by adding the following code:

    /*// Separete Login form and registration form */
    add_action('woocommerce_before_customer_login_form','load_registration_form', 2);
    function load_registration_form(){
    if(isset($_GET['action'])=='register'){
    woocommerce_get_template( 'myaccount/form-registration.php' );
    }
    }
    #895541

    ottobono
    Participant

    Hi, I could personalize my wp_signup.php page. The fact is: I do not like how woocommerce treat the login page, because it is not separated from the register page, then I thought I could use the wp-login.php page for login and the wp-signup page for registrations. If you register your account from wp-signup.php page do you become admin rights or client rights? Another solution would be to split the register and login page… what do you suggest? Thx!

    #896103

    Rad
    Moderator

    Hi there,

    It depends on WordPress’s setting as it will take the role that you set at Admin > Settings > General > New User Default Role . By default, registration is for the subscriber. And you can only create Admin account if you’re logged in as an admin. I think it’s okay with that current role setup.

    Hence, no need for splitting the registration. But, if you’re going to use multiple roles and custom login page. Then that’s when you need a split registration. Since there is only one role (eg. Client), then I guess one page is enough.

    Thanks!

    #896394

    ottobono
    Participant

    Hi Rad, I am the only one admin and I created an account (manually and I have assigned its rights manually) only for my customer, who has to use woocommerce. Maybe I’ll have to create another account for the marketing department (maybe another admin), all other accounts should be customers that want to buy something from the shop. Is my current setup ok?

    P.s. I disable the page wp_signup.php (topic here https://community.theme.co/forums/topic/blank-space-under-footer-problem/#post-896021)

    #897229

    Rad
    Moderator

    Hi there,

    Yes that’s okay, unless you wish to let them signup for their own account. Are you planning to create registrations for specific users?

    Thanks!

    #899990

    ottobono
    Participant

    Hi Rad, the only users that are not admin and can register are customers, all other users will be created manually from me (ie admins, shop manager etc.) 🙂 is it then ok?

    #901349

    Lely
    Moderator

    Hi There,

    That is ok. Just set Admin > Settings > General > New User Default Role to Customers.

    Hope this helps.

    #902259

    ottobono
    Participant

    Hi Lely, I cannot find this setting (there is none) but new users seems to be assigned standard to this role, so no problem anyway! Thank you!

    #903150

    Darshana
    Moderator

    Glad it works for you now 🙂