• Resolved maxii1996

    (@maxii1996)


    Hi, I need change the First and Last Name showed in Approval Tab.
    I’m not using these fields and i want to replace it by a Discord Field (Meta Field called “discord”)

    Can anyone help me? Thanks.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Paul

    (@paulplapsa)

    Hello @maxii1996,

    Thank you for reaching out to us.

    Something like this should work:

    /*
     * Add Extra Column inside the Admin Approval page
     * Replace custom_field_1 with the meta-name of the field you want to display and 'Custom Field 1' with the name you wish to display in the table head
     */
    
    add_filter('wppb_admin_approval_page_columns','wppbc_add_extra_column_inside_admin_approval');
    function wppbc_add_extra_column_inside_admin_approval ($column){
        $column['custom_field_1'] = 'Custom Field 1';
        return $column;
    }
    
    /*
     * Optionally, you can make the column sortable
     */
    
    add_filter('wppb_admin_approval_page_sortable_columns', 'wppbc_make_extra_column_inside_admin_approval_sortable');
    function wppbc_make_extra_column_inside_admin_approval_sortable() {
        $column['custom_field_1'] = array('custom_field_1',false);
        return $column;
    }
    
    add_filter('wppb_admin_approval_page_manage_column_data','wppbc_add_data_inside_extra_column',10,2);
    function wppbc_add_data_inside_extra_column($array,$user){
        $array['custom_field_1'] = get_user_meta($user->ID, 'custom_field_1', true); // replace custom_field_1 with your field meta-name
        return $array;
    }
    
    /*
     * Remove the First Name and the Last Name columns
     */
    
    add_filter('wppb_admin_approval_page_columns','wppbc_remove_columns_inside_admin_approval');
    function wppbc_remove_columns_inside_admin_approval ($column){
        unset($column["first_name"]);
        unset($column["last_name"]);
        return $column;
    }

    You can use this code by adding it to your theme’s ‘functions.php’ file or by creating a new plugin as described here. Just remember to replace the items mentioned in the comments.

    Best Regards,
    Paul

    • This reply was modified 4 years, 5 months ago by Paul.
    Thread Starter maxii1996

    (@maxii1996)

    Wow @paulplapsa Really Thanks!!

    It works perfect! Excelent Job! ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Change the First And Last Name for Custom field’ is closed to new replies.