Support » Plugin: Product Customer List for WooCommerce » Displaying author profile link option in the customer list

  • Resolved paxton111

    (@paxton111)


    Hi,

    So I’m trying to add author’s profile link option on the customer’s details list by myself, would appreciate if anyone can help. (That is, to create an option for link to author’s profile like this: example.com/author/username among all other customer details.)

    What I’ve achieved so far:

    I’m collecting author profile links (example.com/author/username) on the Woocommerce checkout form through hidden field. So basically when checkout form is submitted it saves author profile link:

    add_action( 'woocommerce_after_order_notes', 'my_custom_checkout_hidden_field', 10, 1 );
    function my_custom_checkout_hidden_field( $checkout ) {
    
        // Get an instance of the current user object
        $user = wp_get_current_user();
    
        // The user link
        $user_link = home_url( '/author/' . $user->user_login );
    
        // Output the hidden link
        echo '<div id="user_link_hidden_checkout_field">
                <input type="hidden" class="input-hidden" name="user_link" id="user_link" value="' . $user_link . '">
        </div>';
    }
    
    add_action( 'woocommerce_checkout_update_order_meta', 'save_custom_checkout_hidden_field', 10, 1 );
    function save_custom_checkout_hidden_field( $order_id ) {
    
        if ( ! empty( $_POST['user_link'] ) )
            update_post_meta( $order_id, '_user_link', sanitize_text_field( $_POST['user_link'] ) );
    
    }

    What would be other necessary steps to add this field to customer details in WC product customer list?? And how can I enable this option on the Product Customer List for WooCommerce dashboard?

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • In the shortcode.php I managed to display author profile link with this:

    $output .= '<td>' . $order->user_link . '</td>';

    But it’s in the text format – how can I can turn this into hyperlink?

    I’ve tried this but I’m getting an error:

    $output .= "<td> <a href='" . $order->user_link . " '>user</a></td>";

    Plugin Author Kokomo

    (@kokomoweb)

    Paxton, glad you figured out most of it. What link do you need exactly? To a front end profile or to the user admin in the backend?

    Plugin Author Kokomo

    (@kokomoweb)

    seems you had the answer in your previous message:
    $user_link = home_url( ‘/author/’ . $user->user_login );

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Displaying author profile link option in the customer list’ is closed to new replies.