• Resolved dkance

    (@dkance)


    Hi,

    I would like to use the first_name meta_key for an email text.

    I got the following query code which displays a blank space:

    SELECT meta_value as value FROM wp_usermeta where meta_key='first_name' and user_id=%user_id%

    How do I customize this query for UM?

    Thanks.

    Regards.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter dkance

    (@dkance)

    Hi @aswingiri @champsupertramp @missveronicatv

    I would greatly appreciate some orientation on whether there is something wrong with the above query for retrieving the “first_name” meta_key for a UM user.

    I would like to insert in on an email text. It currently displays a blank space.

    Thanks.

    Regards.

    Plugin Support Aswin Giri

    (@aswingiri)

    Hello @dkance

    The above-given SQL query is correct and should return the first_name of the user. I believe you are passing actual user_id where you have ‘%user_id%‘.

    If you want to test if the query is working or not, you can pass the user_id of a user that exists on the database.

    @dkance

    First within UM you can use:

    um_fetch_user( $user_id );
    $first_name = um_user( 'first_name' );

    Second {first_name} is a valid placeholder for UM Emails:

    https://docs.ultimatemember.com/article/1340-placeholders-for-email-templates

    Why do you need to code a MySQL SELECT statement?

    Thread Starter dkance

    (@dkance)

    Hi @aswingiri, @missveronicatv,

    I used an actual user id and it came out blank.

    The query code is for inserting the first_name on an automatic email booking confirmation sent using the Appointment Hour Booking plugin.

    I am using a hidden field that retrieves the user first_name for that field tag that is inserted on an email text.

    Not sure why it is not working.

    Thanks!

    Regards

    Plugin Support Aswin Giri

    (@aswingiri)

    @dkance I believe you are saving query results in a variable and then passing it to a field? can you post the full code you are using to retrieve first_name? Please check this example.

    I tested the query on my database and it’s working just fine. Maybe it’s the issue of how you are executing it and how you are passing value?

    Thread Starter dkance

    (@dkance)

    Hi @aswingiri, @missveronicatv,

    I finally resolved the issue with your advice.

    Thanks a lot!

    Regards.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Retrieve first_name meta_key query’ is closed to new replies.