Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to use import members from CSV file Add On combined with … #31

Open
wants to merge 15 commits into
base: dev
Choose a base branch
from

Conversation

MaximilianoRicoTabo
Copy link
Contributor

…Group accounts Add On

  • Hook into after import action to insert parent and child accounts.

All Submissions:

Changes proposed in this Pull Request:

Resolves #30 .

How to test the changes in this Pull Request:

  1. Create a parent level
  2. Create a child level
  3. Build a CSV file with the needed columns (Are documented in the source)
  4. Run the import
  5. Check the database.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you successfully run tests with your changes locally?

Changelog entry

Enter a summary of all changes on this Pull Request. This will appear in the changelog if accepted.

…Group accounts Add On

 * Hook into after import action to insert parent and child accounts.
 * Rename hook callback function name
 * Add few WPCS tweaks.
 * cast to int values to insert, the same way the addon does in other places
…Group accounts Add On

 * Hook into after import action to insert parent and child accounts.
 * Rename hook callback function name
 * Add few WPCS tweaks.
 * cast to int values to insert, the same way the addon does in other places
If owner is passed is a child account
@MaximilianoRicoTabo MaximilianoRicoTabo force-pushed the enhancement/add-support-for-IUFCSV branch from 9ad648b to 439e9ea Compare February 25, 2024 23:32
@dparker1005 dparker1005 force-pushed the enhancement/add-support-for-IUFCSV branch from 5225b7e to 71b7b67 Compare February 26, 2024 14:43
andrewlimaza and others added 6 commits February 26, 2024 17:19
* Change aproach to just update seats for group accounts
* Create Group Member account if the level can be claimed with a code.
* Reworked import members from CSV logic.
Copy link
Member

@dparker1005 dparker1005 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we're getting close here, but it feels like there are still a few tricky situations to work through. Going to hold off on merging this PR for the time being

$group_level_settings = pmprogroupacct_get_settings_for_level( $membership_id );
$parent_group = PMProGroupAcct_Group::get_group_by_parent_user_id_and_parent_level_id( $user->ID, $membership_id );
$group_id = $user->pmprogroupacct_group_id; // Child accounts would pass through the Group ID.
$seats = ! empty( $user->pmprogroupacct_group_total_seats ) ? intval( $user->pmprogroupacct_group_total_seats ) : $group_level_settings['max_seats'];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we always want to default to the max seats for a group, or if the number of seats is not specified, do we instead just not want to alter group seat data?

if ( ! empty( $parent_group ) ) {
//Update seats if the user has a total seats value from CSV.
$parent_group->update_group_total_seats( $seats );
} elseif ( empty( $group_id ) ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is tricky. I think we only want to create a new group if:

  1. The level being imported is a group level
  2. The number of seats for the group to be created with is specified

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

I can't find the required csv structure for using this code.
Can you help me ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support to use import members from CSV file Add On combined with Group accounts Add On
4 participants