• Resolved jlamerto

    (@jlamerto)


    Hi,

    I’m looking at a way to add/update user_metadata for a given user, similar to the example given in this thread I found, however it is old and uses methods ie. “WP_Auth0_Api_Client::update_user()” that are now depreciated in version 3.10.0 of the plugin.

    I have found examples in php class in `WP_Auth0_Profile_Change_Email.php’ however i’m not sure how to go about useing it.

    Can someone show me the proper way to update/add user_metdata using the WP_Auth0 SDK in the plugin?

Viewing 6 replies - 1 through 6 (of 6 total)
  • @jlamerto – Happy to help. Are you looking to do that in a custom plugin/theme? I just want to make sure I have the right context here.

    The WP_Auth0_Profile_Change_Email.php does most of the heavy lifting for that specific process but the actual API call is made using WP_Auth0_Api_Change_Email. You can structure the WP hook however you’d like then follow the example of WP_Auth0_Api_Change_Email to make the call.

    Thread Starter jlamerto

    (@jlamerto)

    Thanks for responding Josh. Yes I’m looking to do a custom theme profile page. How would I go about calling the change email class from within my theme?

    Should something like this work:
    $results = new WP_Auth0_Api_Change_Email( $user_id, “changed@email” );

    You need a few extra classes to make this work as it’s a call to the Management API:

    `
    $options = WP_Auth0_Options::Instance();
    $client_credentials = new WP_Auth0_Api_Client_Credentials( $options );
    $api_change_email = new WP_Auth0_Api_Change_Email( $options, $client_credentials );
    $results = $api_change_email->call( ‘user_id_here’, ‘new_email_here’ );
    `

    Written in the editor and not tested ??

    Thread Starter jlamerto

    (@jlamerto)

    That’s great thanks, I’ll have a play with your example next week.

    Thread Starter jlamerto

    (@jlamerto)

    Just wanted to say that worked. Thank you Josh.

    Great to hear and happy to help! Thank you, as well, for checking back in ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How can I add/update user_metadata using WP_Auth0?’ is closed to new replies.