-
Author
-
October 29, 2013 at 16:25 #5353hughmParticipant
I am using a plugin called BP Registration Options to hold newly registered users in an approval workflow while they complete their profile. Once I see that they have uploaded their avatar and completed all of their profile fields, I then approve them.
This plugin hides the user profiles from view while they are waiting to be approved, so they do not appear on the search listings. However these partially completed profiles do appear when users click the Quick Profile Navigation buttons.
How can I hide these pending user profiles from the Quick Profile Navigation?Here is the code from BP Registration Options that hides the newly registered unapproved user profiles:
COPY CODE/** * Custom activation functionality */ add_action( 'bp_core_activate_account', 'wds_bp_registration_options_bp_core_activate_account'); function wds_bp_registration_options_bp_core_activate_account($user_id){ global $wpdb, $bp_moderate; if ( $bp_moderate && $user_id > 0 ) { if ( isset( $_GET['key'] ) ) { //Hide user created by new user on activation. $sql = 'UPDATE ' . $wpdb->base_prefix . 'users SET user_status = 69 WHERE ID = %d'; $wpdb->query( $wpdb->prepare( $sql, $user_id ) ); //Hide activity created by new user $sql = 'UPDATE ' . $wpdb->base_prefix . 'bp_activity SET hide_sitewide = 1 WHERE user_id = %d'; $wpdb->query( $wpdb->prepare( $sql, $user_id ) ); //save user ip address update_user_meta( $user_id, 'bprwg_ip_address', $_SERVER['REMOTE_ADDR'] ); //email admin about new member request $user = get_userdata( $user_id ); $user_name = $user->user_login; $user_email = $user->user_email; $mod_email = $user_name . ' ( ' . $user_email . ' ) ' . __( 'would like to become a member of your website, to accept or reject their request please go to ', 'bp-registration-options') . admin_url( '/admin.php?page=bp_registration_options_member_requests' ); $admin_email = get_bloginfo( 'admin_email' ); wp_mail( $admin_email, __( 'New Member Request', 'bp-registration-options' ), $mod_email ); } } } add_action( 'bp_pre_user_query_construct', 'bp_registration_hide_pending_members' ); /** * Hide members, who haven't been approved yet, on the frontend listings. * @param object $args arguments that BuddyPress will use to query for members * @return object amended arguments with IDs to exclude. * @since 4.1 */ function bp_registration_hide_pending_members( $args ) { global $wpdb; $ids = array(); $sql = "SELECT ID FROM " . $wpdb->base_prefix . "users WHERE user_status IN (2,69)"; $rs = $wpdb->get_results( $wpdb->prepare( $sql, '' ), ARRAY_N ); //Grab the actual IDs foreach( $rs as $key => $value) { $ids[] = $value[0]; } if ( $ids ) $args->query_vars['exclude'] = $ids; return $args; }
October 30, 2013 at 16:46 #5397SQadminKeymasterHi, We did some changes to the code to support excluding users. Add this code to sweetdate-child/functions.php until next theme version:
COPY CODE/** * Get next profile link * @param int $current_id Displayer user ID * @return string User link */ function bp_next_profile($current_id) { global $wpdb; $extra = ''; $obj = new stdClass(); do_action_ref_array( 'bp_pre_user_query_construct', array( &$obj ) ); if ($obj->query_vars && $obj->query_vars['exclude'] && is_array($obj->query_vars['exclude']) && !empty($obj->query_vars['exclude']) ) { $extra = " AND us.ID NOT IN (" .implode(",",$obj->query_vars['exclude']).")"; } $sql = "SELECT MIN(us.ID) FROM ".$wpdb->base_prefix."users us" . " JOIN ".$wpdb->base_prefix."bp_xprofile_data bp ON us.ID = bp.user_id" ." JOIN ". $wpdb->base_prefix . "usermeta um ON um.user_id = us.ID" . " WHERE um.meta_key = 'last_activity' AND us.ID > $current_id" .$extra; if ($wpdb->get_var($sql) && $wpdb->get_var($sql) !== $current_id ) return bp_core_get_user_domain( $wpdb->get_var($sql) ); else return '#'; } /** * Get previous profile link * @param int $current_id Displayer user ID * @return string User link */ function bp_prev_profile($current_id) { global $wpdb; $extra = ''; $obj = new stdClass(); do_action_ref_array( 'bp_pre_user_query_construct', array( &$obj ) ); if ($obj->query_vars && $obj->query_vars['exclude'] && is_array($obj->query_vars['exclude']) && !empty($obj->query_vars['exclude']) ) { $extra = " AND us.ID NOT IN (" .implode(",",$obj->query_vars['exclude']).")"; } $sql = "SELECT MAX(us.ID) FROM ".$wpdb->base_prefix."users us" . " JOIN ".$wpdb->base_prefix."bp_xprofile_data bp ON us.ID = bp.user_id" ." JOIN ". $wpdb->base_prefix . "usermeta um ON um.user_id = us.ID" ." WHERE um.meta_key = 'last_activity' AND us.ID < $current_id" . $extra; if ($wpdb->get_var($sql) && $wpdb->get_var($sql) !== $current_id) return bp_core_get_user_domain( $wpdb->get_var($sql) ); else return '#'; }
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution -
AuthorPosts
The forum ‘Sweetdate – WordPress’ is closed to new topics and replies.