Adding user metadata to all users

The problem is that you’re using get_current_user_id();. There’s two reasons this is incorrect: The user being created is not necessarily the current user. For example, if an admin creates the user manually. user_register runs immediately after the user is created, but before the user is logged in. So when user_register runs for somebody registering on … Read more

users joined group count in buddypress

To get the group count, use groups_get_user_groups. Find it in: buddypress\bp-groups\bp-groups-functions.php In the members loop, the member id is provided via: bp_member_user_id() You will need to check the member-loop template to find out how to hook into the loop. Or overload that template in your child theme and add a do_action wherever you want it. … Read more

How can I return an error message when updating user meta?

// User Settings Errors add_filter( ‘user_profile_update_errors’, ‘my_plugin_user_settings_errors’ ); function my_plugin_user_settings_errors( $errors ) { $user_level = intval( $_POST[ ‘my-plugin-user-level’ ] ); if ( ! is_int( $user_level ) || $user_level < 0 || $user_level > 50 ) { $errors->add( ‘my-plugin-invalid-admin-level’, ‘<strong>ERROR:</strong> User Level must be between 0 and 50.’ ); } return $errors; }

profile_update works on second update only

Not long after posing this question I figured it out. But since I had spent a few hours looking for the awswer I thought maybe it would be worth posting. I hope this does not break any rules. I changed the default priority from 10 to 11. as per: add_action( ‘profile_update’, ‘initiate_participant_profile_update’, 10, 2 ); … Read more

wp_redirect not working after update_user_meta

wp_redirect sends a HTTP header to the browser. Once HTTP headers are sent, that’s it, they’re gone, you can’t add anymore. However, you called get_header and rendered some HTML. To do this headers need to be sent to the browser telling it to expect a HTML page. So by the time you load edit-profile-proccess.php, it’s … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)