slicewp_get_affiliate()

Description

Retrieves an affiliate from the database by the given ID.

Parameters

slicewp_get_affiliate( $affiliate );
  • $affiliate (int)(required) The affiliate’s ID.

Return

(SliceWP_Affiliate|null) A SliceWP_Affiliate object containing the affiliate data, or null if data for the given affiliate ID doesn’t exist in the database.

Example

The following example shows how you can retrieve the data object for affiliate #10.

$affiliate = slicewp_get_affiliate( 10 );
// Returned value.

SliceWP_Affiliate Object
(
    [id:protected] => 10
    [user_id:protected] => 22
    [date_created:protected] => 2021-08-26 10:48:22
    [date_modified:protected] => 2021-08-26 10:48:22
    [status:protected] => active
    [payment_email:protected] => john_doe@johndoe.com
    [website:protected] => https://johndoe.com/
)

Because the SliceWP_Affiliate object’s properties are protected, to access them you can use the get( $property_name ) method.

$affiliate = slicewp_get_affiliate( 10 );

if ( ! is_null( $affiliate ) ) {

    $user_id = $affiliate->get( 'user_id' );
    $status  = $affiliate->get( 'status' );

}

Was this article helpful?

Do you have any feedback or suggestions to improve this page?

Can't find what you're looking for? We're here to help.

Open a support ticket