Home Forums Plugin Support WP User Frontend Pro If not filled in…

This topic is: not resolved

Tagged: ,

This topic contains 3 replies, has 2 voices, and was last updated by  Nathan 6 years, 1 month ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1869

    Nathan
    Participant
    Post count: 32

    Is there a way to check with a php if statement to check if a form field is not filled in.

    I have created an address form and “address line 2” is not required. Because the address has a comma and a line break at the end of each line, if Address Line 2 is not filled in I would also need to hide the comma and line break.

    For example, I want to show:

    31 Beet Route,
    Some town,
    Some county,
    DY8 2HQ

    NOT

    31 Beet Route,
    ,
    Some town,
    Some county,
    DY8 2HQ

    #1872

    Tareq Hasan
    Keymaster
    Post count: 2831

    Check the meta value existence like this:
    [php]
    if ( $address2 = get_post_meta( $post->ID, ‘address2', true ) ) {
    echo $address2;
    }
    [/php]

    #1875

    Nathan
    Participant
    Post count: 32

    That has worked for one, but not for another:

    <?php if ( $restrictions = get_post_meta( $post->ID, ‘restrictions', true ) ) { echo ‘<dt>Restrictions</dt><dd>'; $restrictions; ‘</dd>'; } ?>

    Any thoughts?

    #1876

    Nathan
    Participant
    Post count: 32

    Fixed it… It was another  global $post; issue!

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘If not filled in…’ is closed to new replies.