>> Display Data From a User

I save data via a form and create newMeta for example mt_carSize, mt_carColor and mt_carWheelSize
How can I do to display data from a specific user not connected, for example user id11 ?
Where can I find a Plugin tutorial for this kind of action if no pl
Thank you

  • Rupok

    Hi Laurent_C,

    Thanks for asking. Are you saving those meta against the user? I mean, are those stored in user_meta ? If yes, then you can easily retrieve and display data for any specific user using the "get_user_meta()" function. You will get full details about this function in the official Codex, here: https://codex.wordpress.org/Function_Reference/get_user_meta

    You will also get example usage code on that Codex page.

    Please let us know if this is not what you are looking for. In that case, can you please add some more details about your requirement so we can understand your query better and provide you better solution? I'm looking forward to hearing from you and resolving this issue as soon as possible.

    Have a nice day. Cheers!

  • Laurent_C

    Hello Rupok !
    Than you for this link, I've got a question related I m gonna to be clear this time :

    Situation : Buddypress with user_meta
    There is a global page with :
    1. a mail form, contactform7 for example
    2. a text field with indicate a user_meta_value created earlier

    Need : Fill the mailto and the specific user_meta_value related with a user_id
    Way to get user_id : a simple qrCode

    How can I display the user_meta_value in the textfield, and direct mail the specific related user_id ?
    find user_meta_value and user email via php ?
    I copy the function and past it in my child theme function.php but I got no result in visual.

    $user_id = 9;
    $key_ln = 'last_name';
    $single = true;
    $user_last = get_user_meta( $user_id, $key, $single );
    echo '<p>The '. $key . ' value for user id ' . $user_id . ' is: ' . $user_last . '</p>';

    Thank you

  • Rupok

    Hi Laurent_C,

    Thanks for the details. Please correct me if I'm wrong, but what I understood is:
    # You have a global contact page
    # A text input field
    # You want to email to the person related with the meta key value entered in that input field

    I'm really sorry but I still have confusion. Can you please provide real meta key for describing your situation? Do you want that someone will enter First Name for example, and then send a message through that contact form and the email will directly go to the user having the first name entered in that input box? Or do you want that the USER ID input box will be filled up by the visitor and then his added details will be emailed to you? Can you please explain these?

    I do apologize for this but if I'm clear, I can give you exact code to solve your issue. I believe, it should not need very complex coding and can be achieved easily. But for writing that working code, I need to understand the situation 100% first.

    I'm looking forward to hearing from you and resolving this issue as soon as possible.

    Have a nice day. Cheers!

  • Laurent_C

    In fact the situation is to contact someone directly.
    the template got 1 contact form and a text field, template empty.

    Mission :
    if someone scan a qrcode, it direct link to a specific page with client user id var.
    It gave when page loaded a string with a client meta, and fill the mailto with the specific client mail
    The aim is to have all client by there qrcode and directly point there mail and display the meta on page

    Thank you

    If you know how can I do it will be great Rupok !

  • Rupok

    Hi Laurent_C,

    I believe, this is possible. Please follow the steps.

    # At first, you will have to create a custom page template. To know how you can create a custom page template, you can check this tutorial: https://premium.wpmudev.org/blog/creating-custom-page-templates-in-wordpress/

    # Then you need to add your custom variable to the public query variables available to WP_Query. You can do this by adding the following lines in your functions.php file or by creating a MU Plugin (I'll prefer a MU Plugin):

    function add_query_vars_filter( $vars ){
      $vars[] = "euserid";
      return $vars;
    add_filter( 'query_vars', 'add_query_vars_filter' );

    # Now in your custom page template, create a form and put value with PHP. A basic form code will look like this (you can copy the following lines to bootstrap your form):

          $user_id = get_query_var( 'myuserid', 1 );
          $user_info = get_userdata($user_id);
          $first_name = $user_info->first_name;
          $last_name = $user_info->last_name;
          $user_email = $user_info->user_email;
    <form action="process.php" method="post">
    First Name: <input type="text" name="first_name" value="<?php echo $first_name; ?>"><br>
    Last Name: <input type="text" name="last_name" value="<?php echo $last_name; ?>"><br>
    E-mail: <input type="text" name="email" value="<?php echo $user_email; ?>"><br>
    <input type="submit">

    Please note, this is just a boilerplate of how you can make this. I've not tested this code. This is just to give you idea how you can implement the user value in form input boxes.

    # And finally, you have to generate QR codes with your contact page URL with "euserid" parameter. Example: "http://www.mysite.com/contact/?euserid=8"

    The euserid value will decide data for which user will be inserted in the form.

    In this way, you can achieve your target I believe.

    Please let us know if you have any confusion or any further query. We will be glad to help.

    Have a nice day. Cheers!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.