Retrieve user data in query loop

Hi
I’m trying to show some user details in query loop, so i use this code from the bricks documentation to make my own dynamic tag.

But unfortunately i cant access to the user meta with the variables in this code.

Note: We can’t use wp_user_meta, because we need to parse the data first, because the way dokan plugin is storing data in database need that.

add_filter( 'bricks/dynamic_data/render_content', 'render_my_tag', 10, 3 );
add_filter( 'bricks/frontend/render_data', 'render_my_tag', 10, 2 );
function render_my_tag( $content, $post, $context = 'text' ) {

  // $content might consists of HTML and other dynamic tags
  // Only look for dynamic tag {my_dd_tag}
  if ( strpos( $content, '{my_dd_tag}' ) === false ) {
    return $content;
  }

  // Do your custom logic here, you should define run_my_dd_tag_logic() function
  $my_value = run_my_dd_tag_logic();

  // Replace the tag with the value you want to display
  $content = str_replace( '{my_dd_tag}', $my_value, $content );

  return $content;
}

Hi @Mehdimoradi ,

I am sorry that don’t really understand your question.

Are you going to create a custom dynamic tag to output current looping data?

Or the dynamic tag not related to the loop, you just wan to get the current login user’s meta?

“But unfortunately i cant access to the user meta with the variables in this code.”
Can you explain what does this means? The documentation just an example on how to create your own dynamic tag.

Regards,
Jenn

1 Like

Thank you for your reply.
I want to get the current user’s meta, but it would be nice to give me what i need to make dynamic tag for both.

let me explain: I’m using dokan (multivendor plugin) and i need to make some dynamic tags to get store banner, store name, store rating and etc. I need to show these tags in vendor (author) page and product page.

example 1: In the product page, i need to show the details of the author/vendor of the current product like store name
example 2: in the author/vendor page, i need to show details of the author like store name, store rating + products published by this vendor

Note: I use this tag {wp_user_id:storename} to show store name. the problem is that its working fine in loop (it shows the store name) but it doesn’t render the store name in vendor/author page or product page.

Hi @Mehdimoradi ,

I am not very sure how does the relationship of a vendor to the product or the page you are currently viewing. Is it confirmed that the product’s author (creator) is the vendor?

I don’t think you can use wp_userxxx dynamic tag to display the store information as it was meant for the current login user.

I would suggest you create some custom PHP function to test before creating dynamic tag. As creating dynamic tag is much more complicated.

Did the dokan plugin provides shortcodes to display those info? If so, you should try my solution to the other plugin’s user here:

Regards,
Jenn