• Resolved GregW

    (@gwmbox)


    In the members-grid.php file (in my child theme) I am trying to check if a field is empty or not.

    If it is then show X, if not then show Y

    I know I can display fields with the three {} each side of the field

    But I can’t get that to work to check if it is empty or not.

    Is there another way I can call or get a value of a field in a php if statement?

    • This topic was modified 6 months, 1 week ago by GregW.
    • This topic was modified 6 months, 1 week ago by GregW.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support yuriinalivaiko

    (@yuriinalivaiko)

    Hello @gwmbox

    The members-grid.php file uses the wp.template library. Please read the document Javascript Reference/wp.template first. With this library you can use tags <# #> to evaluate JavaScript code into the template.

    So, you can use a code like below inside the $tagline_fields or $reveal_fields cycle.

    <# if ( typeof user['<?php echo $key; ?>'] === 'undefined' ) { #>
    show X (empty)
    <# } else { #>
    show Y (not empty)
    <# } #>

    Use a code with a hardcoded key if you wish to add it out of a cycle.

    <# if ( typeof user['facebook'] === 'undefined' ) { #>
    show X (empty)
    <# } else { #>
    show Y (not empty)
    <# } #>

    Regards

    Thread Starter GregW

    (@gwmbox)

    @yuriinalivaiko

    Thanks, but I am not sure if I explained myself or I don’t understand your answer.

    What is typeof user?

    I am looking to see if a field, e.g. my_field, has data in it, not a user type.

    Thanks

    Thread Starter GregW

    (@gwmbox)

    I was able to work it out with your suggestion and that page for more info.

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Members Grid/List check if field empty’ is closed to new replies.