Home Forums Plugin Support WP User Frontend (Free Version) Hook to update user profiles metadata

This topic is: resolved

Tagged: 

This topic contains 2 replies, has 2 voices, and was last updated by  alsur 5 years, 6 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #8319

    alsur
    Participant
    Post count: 4

    We are trying to combine WPUF with the Advanced Custom Fields (ACF) plugin without success. ACF works great for metadata as it generates code for different metadata types with just one call.
    We are following this procedure: http://support.advancedcustomfields.com/forums/topic/front-end-and-custom-user-meta/

    The concept as we understand is that we need to add an action to a hook on the user data saving:

    // $post_id to save against
    $post_id = ‘user_' . $user_id;

    // update the post
    do_action(‘acf/save_post', $post_id);

    We are trying to hook it to ‘wpuf_update_profile' but the metadata seems blank at that stage and we are not sure how to search for an alternative hook while using WPUF for the users front profile edit.

    Thanks

    #8502

    Tareq Hasan
    Keymaster
    Post count: 2831

    Yes, you've to use Action Hook field field. Take a look how to use the action hook field field. Use this kind of code below in render_my_awesome_hook function.
    [php]
    acf_form(array(
    ‘field_groups' => array(130),
    ‘form' => false
    ));
    [/php]

    Now you've to update the field value. In the update_my_brand_new_hook function as given in the example, ACF fields can be found in $_POST['fields'] variable as array. Use wpuf_update_profile action to update the user profile fields.

    #8507

    alsur
    Participant
    Post count: 4

    Thanks. We now paint the ACF form correctly “inside” the WPUF form and we've checked the variables arrive correctly by post, but when we hook to the do_action save of ACF nothing gets saved. I understand this might be out of the WPUF concept but any help or alternative hook to connect to would be appreciated.

    Code we are using currently:


    add_action('acf_form', 'acf_user_metadatas', 10, 3 );
    function acf_user_metadatas( $form_id, $post_id, $form_settings ) {
    acf_form(array(
    'field_groups' => array(54),
    'form' => false
    ));
    }

    function update_my_brand_new_hook( $post_id ) {

    $user_id = wp_get_current_user();

    // $post_id to save against
    $post_id = 'user_' . $user_id;

    // update the post
    do_action('acf/save_post', $post_id);

    //print_r($_POST);
    }

    add_action( 'wpuf_update_profile', 'update_my_brand_new_hook' );

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Hook to update user profiles metadata’ is closed to new replies.