Forum Replies Created
-
@adjunkten You can use the below:
function profile_field_update( $user_id, $posted_field_ids, $errors, $old_values, $new_values ) { if ($old_values[4]['value'] !== $new_values[4]['value']) { $message = sprintf( 'The user: <strong>%1$s</strong> changed his profile field with ID number 4' , bp_core_get_user_displayname( $user_id ) ) . "<br><br>"; wp_mail( $admin_email, $title, $message ); } } add_action( 'xprofile_updated_profile', 'profile_field_update', 10, 5 );
This is just an example how the admin can be notified via email when the user change a specific profile field of him. In the example the profile field has ID with number 4.
Thank for your reply @takashimatsuyama.
I have tried 2 alternatives to solve the problem but without success.
1. I’ve tried to override the language files according to this (2. How to use custom language files) so that i can set my own english traslantion for the components slug . But for some reason the po/mo doesn’t override.
2. I’ve tried to use the filter
bp_get_members_invitations_slug
in https://github.com/buddypress/BuddyPress/blob/master/src/bp-members/bp-members-template.php but again without success.At the moment i just translated the po/mo manually to make to component work.
By something like this i have managed to set a default text-value when the field is empty after saving.
function default_value ( $user_id ) { $default_text = xprofile_get_field_data( 4, $user_id ); if (empty($default_text)) { xprofile_set_field_data( 4, $user_id, "Apparently, this user prefers to keep an air of mystery about them."); } } add_action( 'xprofile_updated_profile', 'default_value');
Which is good.
But i need also to have the field set with the default value from the very start when the field is being created for the user.So i guess i would need to use some othen action or hook for that?
Any help would be appreciated.
hello @shanebp and thank you for your support 🙂
I just tested on my site and if i echo
$user_info = get_userdata( 40 ); echo '<strong>' . $user_info->last_activity . '</strong>';
i get the last activity normal. I also checked in the db in the usermeta table and i found the meta_key with last_activity . Am i missing something?
@canvasstudio i have the same problem. Could you provide me with your solution?
Hello @shanebp , needed to inform you that i get an error with WordPress debug about the code above.
Trying to get property 'roles' of non-object
in line$displayed_user_roles = $displayed_user->roles;
i dont know why.@msteimann if you still need this just tell me i can help you.
So i managed to solve this problem with some CSS, unfortunately there is no possibility to wrap with any html element around
(%s)
, BUT there is possibility to wrap with html the rest. So i did thisprintf( '<span id="keep"><span id="%s" href="#"></span><img src="%s" style="width: 15px"> %s</span> (%s)' . "\n",
with out removing nothing from the original code, just adding the span ‘keep’ and then with the classic css
visibility:hidden;
trick i managed to hide it simple.@clickallco thanks for the reply. Unfortunatelly in legacy it is like that `<li class=”ac_event ac_over”><span id=”link-username” href=”#”></span>
<img src=”https://www.test.com/wp-content/uploads/avatars/23/user-bpthumb.jpg” style=”width: 15px”> User (<strong>U</strong>sername)</li>`and there is no element to hide the
(<strong>U</strong>sername)
Hello, did you manage to find solution to this issue?
Hello, did you manage to find solution to this issue?
So i managed to find the appropriate code in case someone also needs it:
define( 'BP_MESSAGES_AUTOCOMPLETE_ALL', true ); /** * Filter and remove subscribers and user's own mail from all BuddyPress auto complete box. * * @param array $args BP_User_Query args. * * @return array */ function buddydev_filter_buddypress_auto_complete_ids( $args ) { $user_ids = isset( $args['exclude'] ) ? $args['exclude'] : array(); if ( $user_ids && ! is_array( $user_ids ) ) { $user_ids = wp_parse_id_list( $user_ids ); } $excluded = get_users( array( 'role' => 'subscriber', 'fields' => 'ID' ) ); if ( is_user_logged_in() ) { array_push( $excluded, get_current_user_id() ); } $args['exclude'] = array_merge( $excluded, $user_ids ); return $args; } add_filter( 'bp_members_suggestions_query_args', 'buddydev_filter_buddypress_auto_complete_ids' );
with this i can have excluded from autocomplete all subscribes by hooking to
bp_members_suggestions_query_args
hello @andrewteg, i am trying to do the same. Did you figure it out?
I was also thinking that i could skip the use of
define( 'BP_MESSAGES_AUTOCOMPLETE_ALL', true );
and since i just want to have in the autocomplete contributors+adminsit could be a function that makes all of those users friends with out the need of bp friends component?
Or maybe the opposite, just dont allow Subscribers in the result.
Yes @shanebp, this works perfect. Thank you again for your help
Hello @shanebp,
Thank you so much for your help 🙂
I have tried your code (and also changed you lastreturn button;
withreturn $button;
), but it doesn’t work.If i login as subscriber all msg buttons are removed from all users profiles, which is correct.
If i login as contributor i can see msg buttons on contributors and admins profiles , but also on subscribers profiles, which i would like not to.*Lets assume that contributors and admins have ID 23, 6, 25 .
I tried many variations with your code but no luck.