• Resolved Reed Sutton

    (@reedus33)


    I am trying to create a table that displays a list of custom posts which are associated only to the logged in user.

    Can I use the where clause to specify that the custom post type’s field (applicant_username) matches the wp user_email?

    I have tried

    • applicant_username=t.user_email
    • applicant_username.meta_value=t.user_email

    But this isn’t working.

    Thanks for your help.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Paul Clark

    (@pdclark)

    Assuming applicant_username is a field containing an email, applicant_username.meta_value = "{@user.user_email}" works in testing if you set define( 'PODS_SHORTCODE_ALLOW_EVALUATE_TAGS', true ); in wp-config.php. See https://docs.pods.io/displaying-pods/magic-tags/special-magic-tags/

    This type of query may be easier / more efficient if you use either a User Relationship field, which stores an associated user by User ID, or the built-in post_author field.

    • This reply was modified 2 years, 2 months ago by Paul Clark.
    Plugin Support Paul Clark

    (@pdclark)

    To be a bit more thorough, to test this, I created a Pod called test and added a post with an email address of the currently logged in user in an email field called applicant_username. On a Page, I then inserted a Pods Item List block with the following values:

    • Pod Name: test
    • Custom Template: <tr><td><a href="{@permalink}">{@post_title}</a></td></tr>
    • Content Before List: <table>
    • Content After List: </table>
    • WHERE: applicant_username.meta_value = "{@user.user_email}"

    …with define( 'PODS_SHORTCODE_ALLOW_EVALUATE_TAGS', true ); set in wp-config.php

    Thread Starter Reed Sutton

    (@reedus33)

    Thanks worked perfectly!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘WHERE clause with user_email’ is closed to new replies.