• Resolved kuschang

    (@kuschang)


    Hi again Mihai,

    Would it be possible to add admin affiliate table column that show how many affiliate referred by every affiliate on the left? (in numbers). Example, “Tony” has referred 7 new affiliates, so “7” will be displayed besides “Tony”.

    Thanks in advance.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author iova.mihai

    (@iovamihai)

    Hey @kuschang,

    I believe the following code should help with this:

    /**
     * Registers the "referred_affiliates" column in the admin affiliates table, right after the "name" column.
     * 
     * @param array $columns
     * 
     * @return array
     *
     */
    function slicewp_custom_add_affiliate_admin_table_column_referred_affiliates( $columns ) {
    	
    	$columns = array_merge(
    		array_slice( $columns, 1, array_search( 'name', array_keys( $columns ) ) ),
    		array( 'referred_affiliates' => 'Referred Affiliates' ),
    		array_slice( $columns, array_search( 'name', array_keys( $columns ) ) + 1, count( $columns ) )
    	);
    	
    	return $columns;
    	
    }
    add_filter( 'slicewp_list_table_affiliates_columns', 'slicewp_custom_add_affiliate_admin_table_column_referred_affiliates' );
    
    
    /**
     * Appends the HTML that should be shown in the "parent" column of the admin affiliates table.
     * 
     * @param array $row_data
     * 
     * @return array
     * 
     */
    function slicewp_custom_add_affiliate_referred_affiliates_to_affiliate_admin_table_data_row( $row_data ) {
    	
    	if ( empty( $row_data['id'] ) ) {
    		return $row_data;
    	}
    	
    	$affiliates_count = slicewp_get_affiliates( array( 'parent_id' => $row_data['id'] ), true );
    		
    	$row_data['referred_affiliates'] = $affiliates_count;
    	
    	return $row_data;
    	
    }
    add_filter( 'slicewp_list_table_affiliates_row_data', 'slicewp_custom_add_affiliate_referred_affiliates_to_affiliate_admin_table_data_row' );

    Please add the code to your website and let me know how it goes. Also, feel free to adapt it to your needs.

    Thank you and best wishes,

    Mihai

    Thread Starter kuschang

    (@kuschang)

    Yes it works again. You are awesome. Thanks @iovamihai

    Plugin Author iova.mihai

    (@iovamihai)

    Hey @kuschang,

    Happy to hear it’s working nicely! 😃

    Best wishes,

    Mihai

    Thread Starter kuschang

    (@kuschang)

    O yes, can I add this code to the dashboard of affiliate user account page so that user will know how many of affiliates he has already referred?

    Thanks.

    Thread Starter kuschang

    (@kuschang)

    Ok, @iovamihai

    One more thing. How do I make the referred affiliates count column sortable like ascending and descending?

    Regards,
    Rikiez

    Plugin Author iova.mihai

    (@iovamihai)

    Hey @kuschang,

    Unfortunately, due to how the database query system is built, this particular request cannot be implemented.

    We currently don’t have a way to hook that deep into the plugin and alter the returned data by custom added table values.

    As much as I’d love to help you out with this, currently I’m afraid that I don’t have a solution.

    Best wishes,

    Mihai

    Thread Starter kuschang

    (@kuschang)

    Ok no problem. Thanks anyway.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Add admin affiliate table column show how many affiliate referred.’ is closed to new replies.