Hello great team 🙂
I am using the
xprofile_updated_profile
hook to pass an action but i would like to know if it is possible to pass the action:
1. only when fields from one specific field group are getting updated
2. when the fields are actually with new values.Something like:
`add_action( ‘xprofile_updated_profile’, ‘my_action’ );
function my_action {
if ( group of fields with id || group of fields with id ) {
//do action
}`I don’t want to trigger my action just when user is clicking the save button in general.
Thank you for your help.
Hello Lefteris,
Thank you for posting. BuddyPress does not provide any specific hook for specific field group update. But you can check field group updates in the following way:
add_action( 'xprofile_updated_profile', function ( $user_id, $post_field_ids, $errors, $old_values, $new_values ) { // Check the field group exists. if ( ! bp_is_action_variable( 'group' ) || ! bp_action_variable( 1 ) ) { return; } $group_id = bp_action_variable( 1 ); // Check for your field group ids. $check_for_ids = array( 2 ); if ( in_array( $group_id, $check_for_ids ) ) { // work with your code here. } }, 10, 5 );
Please try it and let me know if it helps or not.
Regards
Ravi
The topic ‘ [Resolved] Hook when profile fields are updated from specific group.’ is closed to new replies.