• Resolved raesitka

    (@raesitka)


    I am working on a member directory and I created a custom template and I have my fields displayed, but some members will not have the fields, so I was wondering what the “if” array would be?

    An example of code:

    <a href="tel:<?php $business_phone_1 = um_user('business_phone_1'); echo $business_phone_1; // prints the user's business number ?>"><?php $business_phone_1 = um_user('business_phone_1'); echo $business_phone_1; // prints the user's business number?></a>

    • This topic was modified 2 years, 9 months ago by raesitka.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Aswin Giri

    (@aswingiri)

    Hello @raesitka

    Please try following code snippet:

    <?php 
    $business_phone_1 = um_user('business_phone_1');
    if( $business_phone_1 ): ?> <a href="tel:<?php $business_phone_1 = um_user('business_phone_1'); echo $business_phone_1; ?>"><?php  echo $business_phone_1; ?></a> <?php endif; ?>
    Thread Starter raesitka

    (@raesitka)

    Great – thanks!

    Plugin Support Ultimate Member Support

    (@ultimatemembersupport)

    Hi @raesitka

    Thanks for letting us know. Please add the escape function before concatenating it to the field to avoid an XSS issue. Please try the following:

    <?php 
    $business_phone_1 = um_user('business_phone_1');
    if( $business_phone_1 ): ?> <a href="tel:<?php $business_phone_1 = um_user('business_phone_1'); echo esc_attr( $business_phone_1 ); ?>"><?php  echo 
     esc_attr( $business_phone_1 ); ?></a> <?php endif; ?>

    Regards,

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Show field on custom template only if it is filled out’ is closed to new replies.