BuddyDev

Search

Replies

  • Participant
    Level: Enlightened
    Posts: 126
    Hervé on in reply to: filter the buddypress members in the list of members #14159

    Hello Brajesh

    form#profile-edit-form div.editfield.field_503 {display:none!important} /* masque le champ 503 (onglet apparence) */
     tr.field_503 {display:none!important}

    I think I css them are good!?

    I submit the change. It must be understood that your code works well. This is your warning that I would not want to have a problem later

    Regards

    
    add_action( ‘bp_pre_user_query_construct’, ‘buddydev_filter_members_list_herve’, 0 );
    function buddydev_filter_members_list_herve( $query ) {
    if ( bp_is_members_directory() ) { ////////////////////// bp_is_members_directory()
    if ( ! is_user_logged_in() ) {
    return;
    }
    ...
    
    /* EX buddy a $user_id = get_current_user_id();
    // get the value for the field.
    // Use field id for better performance.
    $searching_for = xprofile_get_field_data( ‘I search’, $user_id, ‘comma’ ); */
    
    if ( empty( $recherche_de ) ) {
    return;
    }
    
    /////////////////////////////******************if ( bp_is_user_friends() ) {
    return;// do not filter on the friends page. It will be problemetic as it won’t filter the widget/shortcode on the friends page.
    } *********************////////////////////////
    
    $xprofile_query = isset( $query->query_vars[‘xprofile_query’] ) ? $query->query_vars[‘xprofile_query’] : array();
    $xprofile_query[] = array(
    ‘field’ => $field_jesuis,
    ‘value’ => $recherche_de,
    ‘compare’ => ‘=’,
    );
    
    //photo_priorite
    $xprofile_query[] = array(
    ‘field’ => ‘photo_priorite’,
    ‘value’ => 3,
    ‘compare’ => ‘>=’,
    ‘type’ => ‘NUMERIC’,
    );
    
    if ( ! empty( $xprofile_query ) ) {
    $query->query_vars[‘xprofile_query’] = $xprofile_query;
    }
    return $query;
    
    } ////////////////////// bp_is_members_directory() END
    }
  • Participant
    Level: Enlightened
    Posts: 126

    Thank you for this help too
    Previous post to delete because I was wrong wire

  • Participant
    Level: Enlightened
    Posts: 126
    Hervé on in reply to: filter the buddypress members in the list of members #14141

    Hello Brajesh

    Another big thank you for the help given.

    For the masking of the field, it is only possible to restrict the display of the field to “me” (to my knowledge with buddypress). There is a plugin (obsolete) https://fr.wordpress.org/plugins/buddypress-admin-only-profile-fields/ so that the administrator is the only person who sees it but I still have the masking by css

    For the filling, I’m looking but not sure that I can do it with a single request!

    As I did not understand in the code, the warning that there could be a problem “do not filter on the friends page. It will be problemetic as it won’t filter the widget/shortcode on the friends page”. I wonder if this could improve the code

    add_action( ‘bp_pre_user_query_construct’, ‘buddydev_filter_members_list_herve’, 0 );
    function buddydev_filter_members_list_herve( $query ) {
    if ( bp_is_members_directory() ) { ////////////////////// bp_is_members_directory()
    if ( ! is_user_logged_in() ) {
    return;
    }

    $user_id = get_current_user_id();
    $field_jesuis = ’57’;
    $field_jerecherche = ’60’;
    $recherche_de = xprofile_get_field_data( $field_jerecherche, $user_id );

    /* EX buddy a $user_id = get_current_user_id();
    // get the value for the field.
    // Use field id for better performance.
    $searching_for = xprofile_get_field_data( ‘I search’, $user_id, ‘comma’ ); */

    if ( empty( $recherche_de ) ) {
    return;
    }

    /////////////////////////////******************if ( bp_is_user_friends() ) {
    return;// do not filter on the friends page. It will be problemetic as it won’t filter the widget/shortcode on the friends page.
    } *********************////////////////////////

    $xprofile_query = isset( $query->query_vars[‘xprofile_query’] ) ? $query->query_vars[‘xprofile_query’] : array();
    $xprofile_query[] = array(
    ‘field’ => $field_jesuis,
    ‘value’ => $recherche_de,
    ‘compare’ => ‘=’,
    );

    //photo_priorite
    $xprofile_query[] = array(
    ‘field’ => ‘photo_priorite’,
    ‘value’ => 3,
    ‘compare’ => ‘>=’,
    ‘type’ => ‘NUMERIC’,
    );

    if ( ! empty( $xprofile_query ) ) {
    $query->query_vars[‘xprofile_query’] = $xprofile_query;
    }
    return $query;

    } ////////////////////// bp_is_members_directory() END
    }

    Regards

  • Participant
    Level: Enlightened
    Posts: 126
    Hervé on in reply to: filter the buddypress members in the list of members #14111

    Hello Brajesh

    Great 🙂 , it seems to work on the test site.
    I need on the production site to create a xprofle field and fill it for everyone to 3 (I mean by sql!?) Because otherwise it does not work

    Since this is not a member-managed field.
    How can I hide this field for members when viewing their profile?

    Regards

  • Participant
    Level: Enlightened
    Posts: 126

    Hello Brajesh

    Ok, it’s not very urgent because it works for now. It is not worth working on a big development to solve this problem.
    If there is not a simple function to hide the “delete my photo” button, I will set up a css
    Regards

  • Participant
    Level: Enlightened
    Posts: 126
    Hervé on in reply to: filter the buddypress members in the list of members #14002

    Hello Brajesh
    little reminder
    Thank you

  • Participant
    Level: Enlightened
    Posts: 126

    Hello Brajesh

    Is there a possibility to hide the “remove” button by program (hook)?
    otherwise I look to do it with css (less well I do)!
    Regards

  • Participant
    Level: Enlightened
    Posts: 126

    Hello Brajesh

    Yes I understand. I explain the context:
    I want to force a new member to fill out mandatory fields and upload a profile picture.
    * If ok role change: member0 (plan0 with another plugin)
    * Otherwise role subscriber

    With a member management plugin:
    * If role subscriber: he can not have access to some pages (including groups, activity …)

    If he changes his picture no change to the wordpress role
    If it removes the photo back to the subscriber role

    I have an error:
    Parse error: syntax error, unexpected ‘public’ (T_PUBLIC), expecting end of file in/
    public function log_deleted( $args )

    I submitted last version on gist

    If too difficult, is there a way to remove with a hook the button “delete the photo” if not by css

    Regards

  • Participant
    Level: Enlightened
    Posts: 126

    Hi Brajesh,

    OK it works, unfortunately if the member deletes his picture, his role is not changed to “subscriber”
    Is it possible to tell when a member changes their photo or deletes their photo?
    If it’s not possible, I stay with this mofiication
    Regards

  • Participant
    Level: Enlightened
    Posts: 126

    Re
    I believe this comes from the code, to handle the case where the member removes his photo :

    
    public function mark_incomplete_profile( $user_id ) {
    		do_action( 'arm_apply_plan_to_member', 1, $user_id); // 10/01/18: HD AJOUT pour rejoindre plan sans profil finalisé (& role: subscriber)
    		return delete_user_meta( $user_id, '_has_complete_profile' );
    	}

    If a member changes their profile picture, does buddypress use an event believing that the profile picture has been deleted?

    This request is more important than my other request because there are several people who have seen their role / plan changed abnormally
    Regards