• Resolved hrsms

    (@hrsms)


    I have a pod that extends User
    I also have a pod for a collection of reference items that has a relationship field to User.
    
    Hard-coding for user #2 works.
    
    [pods name="reference_collection" where="member.ID=2" pagination="true" template="Individual Collection Template"]
    
    But this fails
    
    [pods name="reference_collection" where="member.ID={@user.id}" pagination="true" template="Individual Collection Template"]
    
    Clearly there is something I do not understand about this magic tag.  Can you help?
    • This topic was modified 3 years, 11 months ago by hrsms.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter hrsms

    (@hrsms)

    I have to admit I do not understand the meta fields. From the documentation:

    {@user.any} is equivalent to getting the ‘any’ field from the currently logged in user, whether it’s a meta field or a core field like user_login.

    In the example given, they are querying the pod that extends users. Does it only work in that case? Can I not use it in a pod that has a User field?

    [pods name=”user” where=”id = {@user.id}”]Hello! {@display_name}[/pods]

    • This reply was modified 3 years, 11 months ago by hrsms.
    • This reply was modified 3 years, 11 months ago by hrsms.
    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @hrsms

    Magic tags are parsed before any shortcodes. That is one thing to keep in mind.
    When using {@user.#} you are referring to the currently logged in user.

    Where are you using this shortcode exactly?

    Cheers, Jory

    Thread Starter hrsms

    (@hrsms)

    Where are you using this shortcode exactly

    Thanks for taking the time to reply. Unfortunately, I’m not sure how to answer. Do you want the url, or a better explanation of what I initially wrote?

    Since I am currently hard-coding the value to my own ID, I did not include a url to begin with. It is https://www.hrsms.org/Content/your-library-detailed-listing/.

    This explains my case more fully:

    • Pod “user” extends the WordPress users.
    • Pod “reference_titles” refers to reference materials for the subject of our site (ship models)
    • Pod “reference_editions” refers to specific editions of “reference_titles”. There is a relationship field to “reference_titles”. The relationship is two-ways – “reference_titles” links back to the editions. You can see it on this page that lists all the titles and the known editions for each. Look at “Built-Up Ship Models” to see the only current example with more than one edition. It is a work in progress, so only a handful of items are entered so far, and I do not have a front end for this yet.
    • Pod “reference_collection” is for “reference_editions” owned by one individual. “reference_editions” is for all items owned by all users. “reference_collection” has 2 relation fields, one to “reference_editions” and one to a “user”

    I want to have a page that displays the collection for the currently logged in user.

    I tried the following, but it did not work.

    [pods name=”reference_collection” where=”member.ID={@user.id}” pagination=”true” template=”Individual Collection Template”]

    If I replace {@user.id} with 2, as shown below, then I successfully get my own listing. This is what is currently on the previous link.

    [pods name=”reference_collection” where=”member.ID=2″ pagination=”true” template=”Individual Collection Template”]

    If you need more information, please let me know. I know your time for free support is limited and I appreciate your help very much.

    Regards,

    Greg

    • This reply was modified 3 years, 11 months ago by hrsms.
    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @hrsms

    Just to be sure, did you enable magic tag support for shortcodes?
    https://docs.pods.io/displaying-pods/magic-tags/special-magic-tags/

    Important: In many cases, such as inside a shortcode, or in the Pods widget settings, you must add the following define(‘PODS_SHORTCODE_ALLOW_EVALUATE_TAGS’,true); to your wp_config.php for these tags to be used.

    Cheers, Jory

    Thread Starter hrsms

    (@hrsms)

    Feeling pretty sheepish right now. I admit that I’ve seen the information about PODS_SHORTCODE_ALLOW_EVALUATE_TAGS before, but I did not bother to check my config file because I was SO VERY confident that I was already using other magic tags (other than {@user}) elsewhere on my site. Well I must be mistaken, because it was not defined, and now that it is, {@user} is working as expected. So sorry to have wasted your time again.

    • This reply was modified 3 years, 11 months ago by hrsms.
    Plugin Author Jory Hogeveen

    (@keraweb)

    No problem!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Where field = Current user’ is closed to new replies.