• Resolved stosun

    (@stosun)


    Hello,
    I aim to automatically write the some profile fields to another database table when the profile page is updated.
    I can write a function for this.
    But how can I make that this function runs when I click the Update profile button?
    Are there any snippets etc about this?
    What advice would you give me?

    Best Regards

Viewing 8 replies - 1 through 8 (of 8 total)
  • @stosun

    You can use the “um_user_edit_profile” action hook.

    https://ultimatemember.github.io/ultimatemember/hooks/um_user_edit_profile.html

    After User Registration you can use the “um_after_save_registration_details” action hook.

    https://ultimatemember.github.io/ultimatemember/hooks/um_after_save_registration_details.html

    Thread Starter stosun

    (@stosun)

    Hi Missveronica,

    Thank a lot foryour quick reply.

    I tried to use um_user_edit_profile hook.

    Testing purpose, I add print_r or echo for $post, $form_data in function my_user_edit_profile to view data at display .

    But I couldn’t get anything.

    Could you have any advise how I can view data values.

    Best Regards

    missveronica

    (@missveronicatv)

    @stosun

    You should get two arrays when doing a Profile page update,
    but not when updating the User Account page.

    Thread Starter stosun

    (@stosun)

    Hi Missveronica,

    Thanks again for your quick reply.

    Yes, I tried it domainname.com/user/username?um_action=edit page as admin.

    I added below code to Code Snippet.

    function my_user_edit_profile( $post, $form_data ) {
    // your code here
    echo ‘***********‘;

    print_r(‘***’,$post, $form_data );

    }
    add_action( ‘um_user_edit_profile’, ‘my_user_edit_profile’, 10, 2 );

    But I couldn’t get any message at display.

    How can I get any message?

    Thank you very much at adavance for your support.

    Best Regards

    missveronica

    (@missveronicatv)

    @stosun

    To the file defined as error_log with ini_set in wp-config.php
    error_log( print_r( $variable, true ) );

    Thread Starter stosun

    (@stosun)

    Hi Missveronica,

    Thanks again for your valuable support.

    But, unfortunately, hook does not work.

    I login as admin then I try to update user profile; domain.com/user/username?um_action=edit page.

    What could you advise me, please?

    Best Regards

    missveronica

    (@missveronicatv)

    @stosun

    This should work for you, I have changed the action priority to 9.
    Output to debug.log

    function my_user_edit_profile( $post, $form_data ) {
    
        $output  = '<pre>';
        $output .= print_r ( $post, true );
        $output .= '</pre>';
        $output .= '<pre>';
        $output .= print_r ( $form_data, true );
        $output .= '</pre>';
        file_put_contents( WP_CONTENT_DIR . '/debug.log', $output . chr(13), FILE_APPEND  );
    }
    add_action( 'um_user_edit_profile', 'my_user_edit_profile', 9, 2 );
    Thread Starter stosun

    (@stosun)

    Hi Missveronica,

    Thank you very much for your valuable support.

    Yes, it works properly, with above code.

    I rated you with 5 stars and add a revview.

    Best Regards

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Automatically copy some profile fields to another database table’ is closed to new replies.