Home Forums WC Vendors Free Support Display Name = Shop Name?

NOTICE: We've Moved to a Ticket System for Support

As of August 31, 2017 (12am EST) our support forums will be retired (read-only), and we will be moving to a support ticket system.  This will allow us to better organize and answer support requests, and provide a more personalized experience as we assist our customers.

For the time being, we will leave our forums open for reading and learning while we work on creating a more robust Knowledge Base for everyone to use.

If you are a WC Vendors Pro customer please open a support ticket here. 

If you are a WC Vendors user please open a support ticket on the Wordpress.org forums.

The information on this forum is outdated and in most instances no longer relevant. Please be sure to check our documentation for the most up to date information.

https://docs.wcvendors.com/

Thank you to all of our customers!

 

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #2077
    chainznanz
    Participant

    Hey there,

    I’ve managed to set First Name and Last Name as Display Name when a customer logs in. But I’ve not been able to make First Name and Last Name as Shop Name for vendors. Any way I can do that?

    This is the code I used for the former:

    /**
    * Format WordPress User's "Display Name" to Full Name on Login
    * ------------------------------------------------------------------------------
    */
    
    add_action( 'wp_login', 'wpse_9326315_format_user_display_name_on_login' );
    
    function wpse_9326315_format_user_display_name_on_login( $username ) {
        $user = get_user_by( 'login', $username );
    
        $first_name = get_user_meta( $user->ID, 'first_name', true );
        $last_name = get_user_meta( $user->ID, 'last_name', true );
    
        $full_name = trim( $first_name . ' ' . $last_name );
    	
    	 if ( ! empty( $full_name ) && ( $user->data->display_name != $full_name ) ) {
            $userdata = array(
                'ID' => $user->ID,
                'display_name' => $full_name,
            );	
    		 
    	wp_update_user( $userdata );
        }
    }
    

    Thx!

    Edit: That didn’t work 🙁 Here’s the code link: http://pastebin.com/nM8BHXvm

    #2082
    WC Vendors Support
    Participant

    The vendors shop URL is their username, or their store name as defined in the shop settings. Check out in the templates how it saves the shop name. Apply your code to grab the vendors first name and last name and save that as their shop name just like the template does, and you’ll be good to go!

    #2091
    chainznanz
    Participant

    Hi Ben,

    Thank you for replying. I spent a whole day on this, but couldn’t manage to do it. I’m still new to PHP, and understand only a bit of it.

    value=”<?php echo get_user_meta( $user_id, ‘pv_shop_name’, true ); ?>”/> I know pv_shop_name is the Shop Name. I have set up the registration to include first name and last name. I want the first name and last name entered on the form to be replicated in Shop Name field. I’ll really appreciate if you could help me.

    Thanks

    #2095
    WC Vendors Support
    Participant

    If you’re passing $user_id — What is $user_id? 🙂

    Check out: http://codex.wordpress.org/Function_Reference/get_current_user_id

    …..and add some form of that to define $user_id

    Don’t worry about being new. We all were once. 🙂

    #2139
    chainznanz
    Participant

    Hi Ben,
    Thank you for trying, but i’m not understanding this. I’m an idiot. I need to learn PHP before I can do any of this. I’ve just been relying on Google so far. Thanks for being patient with me.

    #2149
    Jamie
    Keymaster

    Hi Chainznaz,

    This gist should do what you want.

    https://gist.github.com/digitalchild/35d4a33509c2c4dcd9ee

    You will see I just added to yours to update the usermeta as required. I haven’t tested it as I don’t have an environment for this but it should work. Let me know how you go.

    cheers,

    Jamie.

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘WC Vendors Free Support’ is closed to new topics and replies.