Empty affiliate fields

Posted in

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

One Response to Empty affiliate fields

  1. antonio August 14, 2017 at 8:30 am #

    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.

We use cookies to optimize your experience on our site and assume you're OK with that if you stay.
OK, hide this message.

Affiliates · Contact · Jobs · Terms & Conditions · Privacy Policy · Documentation · Downloads · Useful Plugins · My Account

Share