Membership ID for Members in Plugin

Hi, i'm looking to get a membership ID number against users in the membership plugin. This would help me greatly if users have any issues, i can simply say, whats your membership ID? I'm surprised this isnt already available in the plugin.
What about using the WP userid - would this be possible and how can I insert the userid into any email communications sent through the membership plugin (shortcode)

  • Michael Bissett
    • Recruit

    Hey @craig, hope you're doing well this evening! :slight_smile:

    If you were to install the Reveal IDs plugin on your site, you could see the users IDs by going to Users -> All Users (you can even sort the results by ID, neat huh?).

    As for a user ID shortcode... hmm. That one's going to require some custom coding.

    You may find this thread to be useful in that regard:

    https://premium.wpmudev.org/forums/topic/custom-constants-for-communications-messages#post-714224

    Let me know if I can be of further assistance here please! :slight_smile:

    Regards,
    Michael

  • craig
    • Design Lord, Child of Thor

    Hi Michael

    ehh sorry, not really that neat i'm affraid. I've acheived that already with a small piece of code added to themes functions.php.

    my main issue is communicating a "membership" id to a member - in this case the default wordpress user id.

    for me, to have a membership plugin, surely this is a great and obvious feature for the plugin?

  • Ash
    • WordPress Hacker

    Hello @craig

    Please use the following code:

    add_filter( 'membership_comm_constants_list', 'my_mem_constant', 20 );
    function my_mem_constant( $const ){
    	$const['%userid%'] = '';
    	return $const;
    }
    
    add_filter( 'membership_commfield_%userid%', 'my_mem_data', 20 );
    function my_mem_data( $userID ){
    	return $userID;
    }

    You can add those codes in your functions.php in the theme, if you think your theme won’t be changed. Otherwise mu-plugins is the best solution. To use mu-plugins, go to /wp-content/ and find the folder with name 'mu-plugins'. If there is no folder in that name, then create a folder, name it 'mu-plugins', create a file inside that, give any name you like and paste the code in there. You don't need to activate that plugin. Mu-plugins means must use plugins, so it will be activated automatically always. If you use mu-plugins then add a php start tag at the beginning of the code.

    Then in communication box use %userid% to get the user ID.

    Hope it helps :slight_smile: Please feel free to ask more question if you have.

    Cheers
    Ash

  • craig
    • Design Lord, Child of Thor

    Hi Ashok

    Thank you very much for your response. However the userid is not displaying in the communications. I added the code as you recommended in mu-plugins folder. This did not work. I then added in theme fuctions.php and got this message

    Fatal error: Cannot redeclare my_mem_constant() (previously declared in /home/pblind/public_html/wp-content/mu-plugins/userid.php:4) in /home/pblind/public_html/wp-content/themes/DynamiX/functions.php on line 778

    I then removed from mu-plugins and only left in functions.php and this still did not work.

    From the error message it seems declaration has worked, just not the display.

    regards Craig

  • Ash
    • WordPress Hacker

    Would you please try this then?

    add_filter( 'membership_comm_constants_list', 'my_mem_constant', 20 );
    function my_mem_constant( $const ){
    	$const['blog_user_id'] = '';
    	return $const;
    }
    
    add_filter( 'membership_commfield_blog_user_id', 'my_mem_data', 20 );
    function my_mem_data( $userID ){
    	return $userID;
    }

    And you have to use bloguserid (with no % sign).

    Cheers
    Ash

  • Hoang Ngo
    • Code Slayer

    Hi @craig,

    I hope you are well today and I'm sorry for the delay.

    Please try this

    add_filter('membership_comm_constants_list', 'user_id_in_comm');
    function user_id_in_comm($commn)
    {
        $commn['%userid%'] = '';
        return $commn;
    }
    
    add_filter('membership_commfield_%userid%', 'user_id_value_in_comm', 10, 2);
    function user_id_value_in_comm($val, $user_id)
    {
        return $user_id;
    }

    So when in the communicate message, please use the %userid% to display the user_id.

    Also, please note that you will need to activate the communicate after created.

    Please give it a try and let us update :slight_smile:.

    Best regards,
    Hoang Ngo

  • Hoang Ngo
    • Code Slayer

    Hi @Cheryl,

    I hope you are well today.

    Great to hear that working for you :slight_smile:. This thread already in the Features & Feedback section, so the developer has noticed about this, so we will have it in future release I think :slight_smile:.

    If you have any issues please don't hesitate to let us know so we can assist

    Best regards,
    Hoang Ngo

  • Webperson
    • Flash Drive

    Hi Hoang

    Is there a way members can see their ID when they log into their profile? Currently the extended profile info is in another tab (not sure that everyone will see that if they are updating their info). Is there a way of customising the profile info they see - do you have a recommended plugin or other suggestion?

    Also to get it out with the extended profile info into a csv file (to get into Mailchimp).

    Many thanks - all questions nearly sorted - membership does everything else I need.

  • Michael Bissett
    • Recruit

    Hey @Cheryl,

    Is there a way members can see their ID when they log into their profile?

    This would take some custom coding I'm afraid, but you'd be more than welcome to post a job for this on our Jobs Board:

    https://premium.wpmudev.org/wordpress-development/

    Currently the extended profile info is in another tab (not sure that everyone will see that if they are updating their info). Is there a way of customising the profile info they see - do you have a recommended plugin or other suggestion?

    The Extended profile info is actually something provided by BuddyPress, that's why you're seeing it in a separate tab.

    What information are you wanting your users to see on the main profile page?

    Also to get it out with the extended profile info into a csv file (to get into Mailchimp).

    I believe my colleague Jack had recommended this plugin on another thread of yours:

    https://wordpress.org/plugins/export-user-data

    Does that not suit your needs?

    Please advise,
    Michael

  • Webperson
    • Flash Drive

    Hi Michael

    Thanks - I think it will be worth getting it coded.

    On the profile page I really just want people to see their name and address details. We need postal address details as well, which is why I added them with Buddy Press - is there a better way? I want them to add those when they subscribe.
    I will try that plugin to export, thanks.

    One other question, when I added the first two people I was able to add them to a level without adding to add them to a subscription - I don't seem to be able to do that now? Has something changed?

    Thanks

    Cheryl

  • Michael Bissett
    • Recruit

    Hey @Cheryl,

    On the profile page I really just want people to see their name and address details. We need postal address details as well, which is why I added them with Buddy Press - is there a better way? I want them to add those when they subscribe.

    BuddyPress's Extended Profiles functionality is the only supported method presently, other methods of adding custom fields to the subscription form would require custom coding.

    One other question, when I added the first two people I was able to add them to a level without adding to add them to a subscription - I don't seem to be able to do that now? Has something changed?

    Hmm... It seems that we've run into a bug here, as reported in this thread:

    https://premium.wpmudev.org/forums/topic/membership-hi-i-just-made-all-update-and-for-a-new-member

    Our developers are already looking into this, so we should be getting an answer about this soon. :slight_smile:

    On a side note, hope your weekend's been going well so far! :smiley:

    Kind Regards,
    Michael

  • Webperson
    • Flash Drive

    Hi Michael
    That's ok - at least I'm not going mad! I had been busy with another site for a week or so and had thought I had forgotten what to do. I think I need to add the subscription for one of the levels anyway as I assume that is what activates the communication (email) to be sent - rather than just adding them to the level?

    I have a couple of coding things so might post those to the jobs board.

    Weekend is good - lovely weather here in New Zealand as we are going in to spring.

  • Michael Bissett
    • Recruit

    Hey @Cheryl,

    That's ok - at least I'm not going mad! I had been busy with another site for a week or so and had thought I had forgotten what to do.

    In that case, glad I could help you keep your sanity! :smiley:

    I think I need to add the subscription for one of the levels anyway as I assume that is what activates the communication (email) to be sent - rather than just adding them to the level?

    If you've created a communication email to be sent from Membership -> Communications, and granted that it's set to "Immediately on signup.", then yes, that's correct. :slight_smile:

    Is it easy to get the fields from the extended profile into the email as well? Ideally I'd like to repeat back to the member the info they gave us.

    Hmm... it would seem possible with an alteration to the code that @Hoang Ngo posted earlier.

    A thread that caught my eye on how this might be accomplished would be this one:

    https://buddypress.org/support/topic/using-xprofile-fields-in-notification-mail/

    Let me call Hoang back here, to see if he has any further thoughts on this. :slight_smile:

    Weekend is good - lovely weather here in New Zealand as we are going in to spring.

    Glad to hear that! We're ever drifting closer to winter over here in the States, but the temperature hasn't gotten too cold yet! :slight_smile:

    Kind Regards,
    Michael

  • Webperson
    • Flash Drive

    Hi Michael

    I have also realised that I should be able to get the members into Mailchimp using the Ping - will give this a go. My only concern is if the member updates their record in membership, does this get passed to Mailchimp? If not it may be easier to to the wholesale csv export each time.

    I have to say I am super impressed with Membership. Love the text widget - have put this in the footer with a link to the private information that the level has access to (at this stage the committee but will be others). It only shows up when they log in - fantastic. Much better than putting it on the menu that is more obvious to others.

    I run another membership site and might consider moving it over - I have one question though that most membership plugins don't seem to have as an option. I want to be able set an exact date that a subscription expires. Essentially it is an online club, they have a financial end of year which is when all memberships end. Can membership do this?

  • Hoang Ngo
    • Code Slayer

    Hi @Cheryl,

    I hope you are well today.

    I have also realised that I should be able to get the members into Mailchimp using the Ping - will give this a go. My only concern is if the member updates their record in membership, does this get passed to Mailchimp? If not it may be easier to to the wholesale csv export each time.

    Yah, you can always using the ping to many purpose. Aslo, the ping will call in those case
    1. User subscribe to new subscription
    2. User from this subscription move to another subscription
    3. User dropped from a subscription
    4. Subscription expired.

    I want to be able set an exact date that a subscription expires. Essentially it is an online club, they have a financial end of year which is when all memberships end. Can membership do this?

    I don't think this currently available with membership 3.5, and this is a complex feature, as the days is dynamic, at the scope of custom coding, we could not provide it :slight_frown:.

    If you need this feature now, you could try posting a job on our job board here https://premium.wpmudev.org/wordpress-development/

    Best regards,
    Hoang Ngo

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.