BuddyDev

Search

How to Update all Existing Profiles’ Visibility

  • Participant
    Level: Initiated
    Posts: 2
    Missio Nexus on #49281

    The BuddyPress Profile Visibility Manager Plugin looks like it only affects users who sign up after the plugin in installed. Is there a script or SQL snipped that we can run on all our users to bulk update all existing profiles with the default visibility settings?

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #49286

    Hello

    Welcome to the BuddyDev Forums. Yes, it can be doable with some lines of code and we will provide you. Please wait till Monday we will get back to you.

    Thank You
    Ravi

  • Participant
    Level: Initiated
    Posts: 2
    Missio Nexus on #49324

    Hi Ravi, thanks for your help. Any update on this?

  • Keymaster
    (BuddyDev Team)
    Posts: 24593
    Brajesh Singh on #49330

    Hi,
    I am sorry, Ravi had asked me to reply on this but I missed.

    I am assuming table names are wp_users and wp_usermeta, Please replace them with your table names.

    1. Delete all the current preference set by any user. This is important step.

    
    DELETE FROM wp_usermeta where meta_key IN ( 'bp_exclude_in_dir', 'bp_exclude_in_search', 'bp_hide_last_active', 'bp_profile_visibility', 'bp_allow_friendship_request', 'bp_friends_list_visibility', 'bp_send_messages_visibility', 'bp_allow_follow_request', 'bp_profile_group_tab_visibility','bp_profile_profile_tab_visibility', 'bp_profile_activity_tab_visibility' );
    
    

    2. For each of the meta key we want to have a default value set, we will need to run something like this
    a. For directory exclusion:-

    
    INSERT INTO wp_usermeta ( user_id, meta_key, meta_value )  SELECT ID, 'bp_exclude_in_dir', 'yes' FROM wp_users
    
    

    Search exclusion:-

    
    INSERT INTO wp_usermeta ( user_id, meta_key, meta_value )  SELECT ID, 'bp_exclude_in_search', 'yes' FROM wp_users
    
    

    Hide last active

    
    INSERT INTO wp_usermeta ( user_id, meta_key, meta_value )  SELECT ID, 'bp_hide_last_active', 'yes' FROM wp_users
    
    

    Profile privacy:-

    
    INSERT INTO wp_usermeta ( user_id, meta_key, meta_value )  SELECT ID, 'bp_profile_visibility', 'friends' FROM wp_users
    
    

    Friendship Request:-

    
    INSERT INTO wp_usermeta ( user_id, meta_key, meta_value )  SELECT ID, 'bp_allow_friendship_request', 'yes' FROM wp_users
    
    

    Friends tab visibility:-

    
    INSERT INTO wp_usermeta ( user_id, meta_key, meta_value )  SELECT ID, 'bp_friends_list_visibility', 'friends' FROM wp_users
    
    

    Message Visibility:-

    
    INSERT INTO wp_usermeta ( user_id, meta_key, meta_value )  SELECT ID, 'bp_send_messages_visibility', 'friends' FROM wp_users
    

    Follow request:-

    
    INSERT INTO wp_usermeta ( user_id, meta_key, meta_value )  SELECT ID, 'bp_allow_follow_request', 'yes' FROM wp_users
    
    

    Group Tab visibility:-

    
    INSERT INTO wp_usermeta ( user_id, meta_key, meta_value )  SELECT ID, 'bp_profile_group_tab_visibility', 'friends' FROM wp_users
    

    Profile Tab visibility:-

    
    INSERT INTO wp_usermeta ( user_id, meta_key, meta_value )  SELECT ID, 'bp_profile_profile_tab_visibility', 'friends' FROM wp_users
    

    Activity tab visibility:-

    
    INSERT INTO wp_usermeta ( user_id, meta_key, meta_value )  SELECT ID, 'bp_profile_activity_tab_visibility', 'friends' FROM wp_users
    

    Please feel free to customize the default values that suits your needs.

    You will need to run all of these via phpMyAdmin or similar mysql admin tool.

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 2
    Missio Nexus on #49429

    Thank you so much for this! Really helpful! This was an incredible time saver.

    One more question: for the Profile Privacy code that you provided, is there a way we can run this and only target certain Profile Types (we’re using buddyboss profile types) — perhaps target the label of the profile type?

  • Keymaster
    (BuddyDev Team)
    Posts: 24593
    Brajesh Singh on #49439

    Hi,
    Thank you for the question.
    I am afraid there is no solution to this. There is not a simple query to fetch all the users from a specific type and that makes it difficult.

    Regards
    Brajesh

You must be logged in to reply to this topic.

This topic is: not resolved