Empty affiliate fields

Hi,
Can you help me?
I’m trying to hide containing div if custom field is empty.

So for example a new registration would have the option to enter a facebook url to their personal facebook profile. On the home page I would have a div container for facebook with a facebook icon and next to the icon their facebook would display. I have this working but it the user does not use facebook and leaves the field empty then I would like to hide the containing div which wraps all this information removing the facebook url placement and icon all wrapped from the one div container.

Thank you,
Derek

Posted in

Comments

One response to “Empty affiliate fields”

  1. Hi Derek,
    The custom affiliate fields are stored as custom user fields, so you can check if the field exists, something like this:
    $user_id = get_current_user_id();
    if ( affiliates_user_is_affiliate( $user_id ) ) {
    if ( get_user_meta( $user_id, 'facebook' , true ) && ( get_user_meta( $user_id, 'facebook' , true ) !== "" ) ) {
    // Display your div here
    }
    }

    You need to change ‘facebook’ to your field name, and add your html div code.
    Kind Regards,
    Antonio B.

Share