bp_admin_tools_default_data_save()
Save dummy data value when dummy data add button is pressed
Description
Source
File: bp-core/bp-core-tools-default-data.php
function bp_admin_tools_default_data_save() { if ( ! empty( $_POST['bp-admin-clear'] ) ) { bp_dd_clear_db(); echo '<div id="message" class="updated fade"><p>' . __( 'Everything was deleted.', 'buddyboss' ) . '</p></div>'; } if ( isset( $_POST['bp-admin-submit'] ) ) { // Cound what we have just imported. $imported = array(); // Check nonce before we do anything. check_admin_referer( 'bp-admin-tools-default-data' ); // Import users if ( isset( $_POST['bp']['import-users'] ) && ! bp_dd_is_imported( 'users', 'users' ) ) { bp_dd_delete_dummy_members_related_data(); bp_delete_option( 'bp_dd_import_users' ); $users = bp_dd_import_users(); $imported['users'] = sprintf( __( '%s new members', 'buddyboss' ), number_format_i18n( count( $users ) ) ); bp_dd_update_import( 'users', 'users' ); } if ( isset( $_POST['bp']['import-profile'] ) && ! bp_dd_is_imported( 'users', 'xprofile' ) ) { $profile = bp_dd_import_users_profile(); $imported['profile'] = sprintf( __( '%s profile field entries', 'buddyboss' ), number_format_i18n( $profile ) ); bp_dd_update_import( 'users', 'xprofile' ); } if ( isset( $_POST['bp']['import-friends'] ) && ! bp_dd_is_imported( 'users', 'friends' ) ) { $friends = bp_dd_import_users_friends(); $imported['friends'] = sprintf( __( '%s member connections', 'buddyboss' ), number_format_i18n( $friends ) ); bp_dd_update_import( 'users', 'friends' ); } if ( isset( $_POST['bp']['import-messages'] ) && ! bp_dd_is_imported( 'users', 'messages' ) ) { $messages = bp_dd_import_users_messages(); $imported['messages'] = sprintf( __( '%s private messages', 'buddyboss' ), number_format_i18n( count( $messages ) ) ); bp_dd_update_import( 'users', 'messages' ); } if ( isset( $_POST['bp']['import-activity'] ) && ! bp_dd_is_imported( 'users', 'activity' ) ) { $activity = bp_dd_import_users_activity(); $imported['activity'] = sprintf( __( '%s personal activity items', 'buddyboss' ), number_format_i18n( $activity ) ); bp_dd_update_import( 'users', 'activity' ); } // Import groups if ( isset( $_POST['bp']['import-groups'] ) && ! bp_dd_is_imported( 'groups', 'groups' ) ) { $groups = bp_dd_import_groups(); $imported['groups'] = sprintf( __( '%s new social groups', 'buddyboss' ), number_format_i18n( count( $groups ) ) ); bp_dd_update_import( 'groups', 'groups' ); } if ( isset( $_POST['bp']['import-g-members'] ) && ! bp_dd_is_imported( 'groups', 'members' ) ) { $g_members = bp_dd_import_groups_members(); $imported['g_members'] = sprintf( __( '%s group members (1 user can be in several groups)', 'buddyboss' ), number_format_i18n( count( $g_members ) ) ); bp_dd_update_import( 'groups', 'members' ); } if ( isset( $_POST['bp']['import-g-activity'] ) && ! bp_dd_is_imported( 'groups', 'activity' ) ) { $g_activity = bp_dd_import_groups_activity(); $imported['g_activity'] = sprintf( __( '%s group activity items', 'buddyboss' ), number_format_i18n( $g_activity ) ); bp_dd_update_import( 'groups', 'activity' ); } if ( isset( $_POST['bp']['import-forums'] ) && ! bp_dd_is_imported( 'forums', 'forums' ) ) { $forums = bp_dd_import_forums(); $imported['forums'] = sprintf( __( '%s forums activity items', 'buddyboss' ), count( $forums ) ); bp_dd_update_import( 'forums', 'forums' ); } if ( isset( $_POST['bp']['import-f-topics'] ) && ! bp_dd_is_imported( 'forums', 'topics' ) ) { $topics = bp_dd_import_forums_topics(); $imported['g_topics'] = sprintf( __( '%s discussion activity items', 'buddyboss' ), count( $topics ) ); bp_dd_update_import( 'forums', 'topics' ); } if ( isset( $_POST['bp']['import-f-replies'] ) && ! bp_dd_is_imported( 'forums', 'replies' ) ) { $topics = bp_dd_import_forums_topics_replies(); $imported['g_replies'] = sprintf( __( '%s reply activity items', 'buddyboss' ), count( $topics ) ); bp_dd_update_import( 'forums', 'replies' ); } if ( isset( $_POST['bp']['import-g-forums'] ) && ! bp_dd_is_imported( 'groups', 'forums' ) ) { $groupsforums = bp_dd_import_forums_in_groups(); $imported['g_forums'] = sprintf( __( 'In %s group forums, discussions and replies were added', 'buddyboss' ), count( $groupsforums ) ); bp_dd_update_import( 'groups', 'forums' ); } ?> <div id="message" class="updated fade"> <p> <?php _e( 'Data was successfully imported', 'buddyboss' ); if ( count( $imported ) > 0 ) { echo ':<ul class="results"><li>'; echo implode( '</li><li>', $imported ); echo '</li></ul>'; } ?> </p> </div> <?php } if ( bp_is_active( 'forums' ) ) { $forum_ids = bp_get_option( 'bp_dd_imported_forum_ids', array() ); if ( ! empty( $forum_ids ) ) { foreach ( $forum_ids as $forum_id ) { bbp_update_forum_topic_count( $forum_id ); bbp_update_forum_reply_count( $forum_id ); } } $topic_ids = bp_get_option( 'bp_dd_imported_topic_ids', array() ); if ( ! empty( $topic_ids ) ) { foreach ( $topic_ids as $topic_id ) { bbp_update_topic_reply_count( $topic_id ); } } } }
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.