Allow Non-User To Update Meta Key Value For A User Profile

Hi All,
I have a use case that is stumping me a bit.

I have a WordPress Site that makes heavy use of Gravity Forms to create robust user profiles. My users have the ability to email a non-user and ask them a yes/no question.

I can't seem to come up with a good way for the non user to click a yes or no link in the email and have the clicked yes/no link update the user's profile with their response.

I basically need to allow a non-user to set a meta field value to yes or no for the user who sent the email. Being a non-user they dont have an account / are not logged in and would need to be setting the meta value for an established user who has the meta key attached to their profile.

Any ideas how I could achieve this?

  • Milan

    Hello @Ian,

    I hope you are having a good day and thanks for the asking. :slight_smile:

    Unfortunately wordpress doesn't allow non-logged user to modify meta values for user by default. For this purpose you need to write some code. By code you can access meta values and do any insert, update, delete, processing for meta for particular user with the help of wordpress meta API.

    Here is one way I think you can use to achieve this. I must say that this is my way of doing things. But you can always ask other developer for better way to achieve this.

    You can send page link along with user id who sent email to non logged in user in mail content. When non-logged in user click on that link, he/she will be redirected to page which will render question and asking answer in yes/no format. When selects answer and submit it to server you can grab user id from user of user who sent mail to non-logged in user and update its meta value with this function https://codex.wordpress.org/Function_Reference/update_user_meta like this,

    if( non_logged_in_user_submitted_answer )
       update_user_meta( $user_id, $meta_key, $meta_value );

    here
    $user_id : user id of user whose meta needs to be updated.
    $meta_key: meta key
    $meta_value: user submitted answer or latest count if you are counting.

    I hope this helps you.

    Please let me know if there is anything else I can help you with.

    Best Regards,
    Milan Savaliya.

  • Ian

    @Milan Thanks for the reply.
    I get the part on how to update the user meta where I'm stumped is how do I grab the url of the user that sent the email? How do I generate a page that can be emailed to contain some of the users meta values and provide the non-user the ability to 1) see it 2) check yes or no.
    Then how do I update the user meta with their response?
    Do I put it all in the url? If Yes - How do I parse it out of the url?
    How do I automatically generate a page containing my copy with the specific users meta values inserted into it?

  • Milan

    Hello @Ian,

    I hope you are having a good day and sorry for being late here. :slight_smile:

    Dear member level of customization you want requires custom development to be done as it requires seamless flow of process to be created for better accessibility and analytic purpose.

    I suggest you hire developer for this or better post your requirement as job on our job portal so that our valuable developer can create this custom flow for you. :slight_smile: You can post job on our job portal here

    https://premium.wpmudev.org/jobs/new-job/

    I hope this helps you.

    Please let me know if there is anything else I can help you with.

    Best Regards,
    Milan Savaliya.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.