Hook to update user profiles metadata

This topic contains 2 reply and 2 voices, and was last updated by alsur 10 years, 6 months ago
Viewing 2 Posts - 1 through 2 (of 2 total)
Author Posts
September 19, 2013 at 10:22 pm 8319
alsur 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
September 27, 2013 at 9:43 pm 8502
Tareq Hasan Tareq Hasan

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.

September 27, 2013 at 11:14 pm 8507
alsur alsur

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 2 Posts - 1 through 2 (of 2 total)