Backend notification when user profile complete
-
I am helping a nonprofit I support by building a site totally built on Buddypress: http://parishcollective.org/beta
We are allowing users to create a profile with minimal information (via Social Login) but we want to keep the user role at ‘subscriber’ until they fill out the required profile fields. At that point, we need to be notified that they updated their info so an admin can check their info and up their role to ‘contributor.’ (It gives them access to creating blog posts and other things)
Initially I started with something basic from this post: http://buddypress.org/support/topic/notification-on-profile-update-2/
However, wp_mail() is conflicting with something in our site and causing a fatal error.
So I’ve been attempting to add a user meta key (when a user updates their profile) that can be queried in the backend in a custom admin menu so the users with completed profiles can be displayed.
Here was the adapted code based on the post above:
function my_update_profile_mark() { $user_ID = get_current_user_id(); $power_level = 9000; add_user_meta( $user_ID, '_level_of_power', $power_level); } add_action( ‘xprofile_updated_profile’, ‘my_update_profile_mark’ );
If I understand the ‘xprofile_updated_profile’ hook correctly, it should just fire anytime any field is updated on a profile, right?
From there I planned to experiment with something like this based on the Force Profile Update plugin to make the function fire when the profile is totally updated:
function my_update_profile_mark() { global $wpdb; $bp_prefix = bp_core_get_table_prefix(); $xprofile_fields = $wpdb->get_results("SELECT count(*) AS empty_fields_count FROM {$bp_prefix}bp_xprofile_fields WHERE parent_id = 0 AND is_required = 1 AND id NOT IN (SELECT field_id FROM {$bp_prefix}bp_xprofile_data WHERE user_id = {$user_id} AND valueIS NOT NULL AND value` != '')"); foreach ($xprofile_fields as $field) { if ($field->empty_fields_count > 0) { $user_ID = get_current_user_id(); $power_level = 9000; add_user_meta( $user_ID, '_level_of_power', $power_level); } add_action( ‘xprofile_updated_profile’, ‘my_update_profile_mark’ );
I’m a pretty new to programming and I don’t totally understand all the code here, but I’m trying hard to make something work here. Any ideas/guidance?
I also realize this solution, even if it worked, would update the meta key ‘_level_of_power’ to the specified value “9000” every time the user updated their profile after their profiles were filled out. But that’s an annoyance we can live with for now. Not knowing the user is ready to be upgraded wouldn’t work at all for the site. Any help would be appreciated. 🙁
- The topic ‘Backend notification when user profile complete’ is closed to new replies.