BuddyDev

Search

Member Types Pro – Database Query

  • Participant
    Level: Master
    Posts: 222
    Mike (DesignServe) on #24428

    Hi Brajesh,

    I’m trying to ascertain, if I know a User’s ID, how I can find out their Member Type, if they have one.

    I’ll post a private reply to this with more detail.

    Regards,
    Mike

  • Participant
    Level: Master
    Posts: 222
    Mike (DesignServe) on #24429
    This reply has been marked as private.
  • Keymaster
    (BuddyDev Team)
    Posts: 24149
    Brajesh Singh on #24440

    Hi Mike,
    Welcome back.

    1. The Member Type entries from the BuddyPress member Types Pro are normal post types, so you can export and import as normal

    2. The Member Type to User association is handled by BuddyPress using custom taxonomy “bp_member_type”.

    If you export the terms association for this taxonomy, You will have the user to member type association preserved(user_id is object id in the term_relationships tab) .

    Hope that helps.

    Regards
    Brajesh

  • Participant
    Level: Master
    Posts: 222
    Mike (DesignServe) on #24447

    Hi Brajesh,

    Thanks. I think I’ve got it. Check for me…

    TABLE: terms_relationships
    object_id = 1 = user_id = me has taxonomy_id = 104

    TABLE: term_taxonomy
    Links term_taxonomy_id (104) with term_id (104)

    TABLE: terms
    term_id = 104 name = communitymember

    So for all members who should be communitymember, in the table terms_relationships:

    object_id (user) needs a taxonomy_id of 104

    Therefore, I can import a list of user_ids with taxonomy_id of 104 into terms_relationships

    Correct?

    I suppose then that I would then run Buddypress Tools to repair counts etc?

    I hoped the plugin I mentioned would help me but I think it won’t in this case.

    Kind regards,
    Mike

  • Keymaster
    (BuddyDev Team)
    Posts: 24149
    Brajesh Singh on #24456

    Hi Mike
    you are correct in assuming the above though there are some issues.

    The object id could be a post id. Object id alone does not guarantee that it is for member type and a user.

    In order to guarantee a user’s member type, we need to do the following.

    1. Find all the term_taxonomy_id in term_taxonomy table where taxonomy=bp_member_type
    2. Now, filter this list by joining to term_relationships on tr.term_taxonomy_id in the above list and object_id = our user id.

    It will give us all the term_taxonomy_id for the user. Now, we need to find the terms for each of the term_taxonomy_id and use that.

    To be honest, a super easy approach will be to write a script that loops through the user and export userid or user_login(which ever does not change) and the member type for the user.

    The another script that reads through this list and sets the member types. I think this script might be very useful for the community and I will love to explore it in future.

    Regards
    Brajesh

  • Participant
    Level: Master
    Posts: 222
    Mike (DesignServe) on #24459

    Hi Brajesh,

    Well I’m starting to understand databases better and thanks for taking this time with me.

    The plugin I mentioned is very good for exporting, adjusting and re-importing. But it’s not going to do what I want because it doesn’t ‘know’ the buddypress fields. I can adjust hundreds or thousands of different values with it quickly, so it is useful for migrating my community anyway.

    Obviously I’m practising with a copy of my multisite multiblog not the main one 🙂

    I’m not moving on with the migration quickly enough so I think I’m going to go back to the migration service I mentioned previously. Your help has been invaluable because I’ll be able to work closely with them to see whether the conversions are working well.

    In the meantime, my members are eager for content so I concentrate on that for a little while in the old system probably.

    It does sound as though the script you describe would be useful.

    Many thanks,
    Mike

  • Keymaster
    (BuddyDev Team)
    Posts: 24149
    Brajesh Singh on #24462

    Hi Mike,
    Thank you.
    I have heard a lot of good things about that plugin for importing and migrating content.

    I am going to plan for allowing user’s member type export too as it can add a lot of value for us in the member types pro plugin.

    All the best with your current plan 🙂

    Regards
    Brajesh

You must be logged in to reply to this topic.

This topic is: not resolved