Include last name on certificate

Home Forums Legacy Support Support queries How-to & Troubleshooting Include last name on certificate

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #36487
    bjorn_beweb
    Participant
    Hello...how do I include the last name for a student on their certificate? When a new student registers via my check-out process, they enter both their first and last name as part of the billing details, but for some reason only the first name makes it to the 'Profile name' which seems to be used for the certificate. I saw another post where it was suggested to use something like this on the certificate: [certificate_student_field field="Last name"] or possibly <span style="line-height: 1.5;">[certificate_student_field field="billing_last_name"] </span><span style="line-height: 1.5;">but I can't get that to work.</span> Is there another way to make this work? I'm happy to use a filter or a hook if that can solve the problem. Thanks, Bjorn
    #36521
    H.K. Latiyan
    Participant
    For this you can ask your users to fill the full name in name field.
    #36749
    bjorn_beweb
    Participant
    Well, the user accounts are created during the checkout process, and the user registration fields are (amongst others) first name and last name, so your suggestion is not really going to work for me. I have tried adding a hook called 'user_register' where I have tried to set the 'display_name' for the wordpress user, but it's not updating the display name or the 'Name' that is used on the 'Extended Profile' tab when editing a user. I've noticed that whatever is entered for 'Name' is used on the certificate. I've also noticed that if I change the Display name in the normal WP user edit page, the 'Name' is also updated. So, my question is this. How can I update the 'Name' field after registering a user. I'm thinking I should be able to use a code such as the one below, but that's not working, so I'm hoping you can tell me how I can update the 'Name' field using a post-registration hook.
    
    add_action('user_register', 'wplms_registration_save', 10, 1);
    
    function wplms_registration_save($user_id)
    {
        if (isset($_POST['billing_first_name']) && isset($_POST['billing_last_name'])) 
        {
            $display_name = sanitize_text_field($_POST['billing_first_name']) . ' ' . sanitize_text_field($_POST['billing_last_name']);
            update_user_meta($user_id, 'display_name', $display_name);
        }
    }
    
    Btw, I've tried to format my code example above a bit better, but it doesn't seem like your editor treats my apostrophies and ambersands very well, but you can probably make out what I'm trying to do.
    #37095
    Anshuman Sahu
    Keymaster
    Well for this you need to match the buddypress profile fields that appears in buddypress register page and woocommerce checkout fields which you can do with the help of a third party plugin  . One of which is : https://wordpress.org/plugins/woocommerce-buddypress-integration-xprofile-checkout-manager/ Note : we have not used this plugin so we cannot say anything that it will fulfill your purpose . Also wordpress automatically fills the display_name field in the database of the user with the first name field that user provide at check out .
    #37159
    RMA
    Spectator
    @ Bjorn - did you get any resolution for this issue? We have the same problem, and they only way to fix it is to go to each user and change in "display publicly as" the first name with full name. It looks like the name on certificate is picked from here, so whatever name shows on "display publicly as", that is what shows on the certificates.
    #37412
    H.K. Latiyan
    Participant
    I am not sure if this is an issue. You already have a short code for this. For example : You have created two custom fields : First name and Last name. So you can simply use the shortcode twice : [certificate_student_field field="First Name"] [certificate_student_field field="Last Name"] --------------- Otherwise whatever is filled by the student in display name appears with the shortcode [vibe_certificate_student_name]   SO as you can see these are two ways to print the name in the certificate. Let me know if I missed something.
    #37458
    bjorn_beweb
    Participant
    @Latiyan that sounds great in theory, but as I said in my original post, these shortcodes does not appear to be working. Have you actually tried this to check that it works? I've tried with both the label names and the actual fields names (billing_first_name, billing_last_name). Even if that worked, another issue would appear as I would need to find a way to make it possible for the students to update those details as at the moment, these details are not available to be updated when logging in as a student. I would much prefer a solution where the 'display publicly as' field defaults to both first name and last name, instead of just first name. It seems a lot more logical to have a student's full name printed on their certificate as opposed to just the first name.
    #37618
    Anshuman Sahu
    Keymaster
    this is the only solution available as of now. Unfortunetely there is no option to match the woocommerce checkout fields and buddypress profile fields available as of now . You can search for third party plugins for this .
    #44651
    info2grow
    Spectator
    Add this to functions.php or your own plugin add_shortcode( 'get_user_fullname', 'get_user_fullname' ); function get_user_fullname(){ global $current_user; get_currentuserinfo(); return $current_user->first_name . ' ' . $current_user->last_name; } Then use the shortcode [<span style="line-height: 1.5;">get_user_fullname]</span>  
    #44738
    H.K. Latiyan
    Participant
    @info2grow: Thanks for sharing the information/code.
    #44787
    info2grow
    Spectator
    no problem, the shortcode should be [get_user_fullname]
Viewing 11 posts - 1 through 11 (of 11 total)
  • The topic ‘Include last name on certificate’ is closed to new replies.