Page 1 of 1

setting a membership ID

PostPosted: October 17th, 2011, 6:20 pm
by plumber
Have searched through the forum but can't find an answer to this fairly simple query.

I'm using s2members more as a membership management tool than an access tool (if you know what I mean) and I need to assign membership numbers as one of the things we need to do is post people out a membership card (it's in the constitution...)

We have lots of people who pay using cheques or cash - rather than paypal - and also quite a lot of people who have paid using paypal in the past - but not via our new site. So the problem I have is trying to coerce everyone on to the site an onto paypal (eventually).

We also have a complex membership payment structure that makes recurring payments difficult. The best I can come up with is making everything Buy Now and forcing expiries after one year. The problem this gives me is that the subscriber ID disappears once the member level reverts to 0 (Free Subscriber)

anyone got any ideas of how I can assign a membership number which will persist through expiries and renewals? Hope that's clear and thanks in advance for any advice or assistance

Re: setting a membership ID

PostPosted: October 17th, 2011, 6:37 pm
by Eduan
So you want people to have their: "Member ID: 7875m8" and that it stays like that?

If so then try this post and see if it helps: viewtopic.php?f=4&t=15492&p=45273&hilit=member+id#p45273

P.S. Remember to report back.

Re: setting a membership ID

PostPosted: October 18th, 2011, 12:48 pm
by plumber
Thanks but that's not really what I was looking for and reading my original post again I don't think I explained it very well - sorry.

I'm looking to set a membership number for every member. We have some members who will sign up with paypal but have a lot who will need to be imported using the import facility and will probably always pay by cash or cheque. My main use of s2members to start with will be a consolidated membership database rather than a means of controlling access to different levels of content - although that is on the roadmap. So I need a unique identifier that will survive membership expiry - the subscriber ID from paypal blanks on expiry. We need to send out a membership card as that is in the club constitution

I couldn't find a way of using a custom field to set up a system generated or pseudo system generated membership ID. Seems such a simple thing to want but I can't find a way of doing it - so far.

Thanks for your reply though

Re: setting a membership ID

PostPosted: October 19th, 2011, 8:12 am
by plumber
I guess there's no answer to this one then? All I'm looking for is a way of assigning a unique number to each account - even manually as we will probably have to set EOT dates on mnually created accounts anyway - so that we can give everyone a permanent membership number that will not be changed by paypal or any other payment gateway. Anyone got any ideas?

Maybe I need to look at another plugin which could add custom fields at a user level

Re: setting a membership ID

PostPosted: October 19th, 2011, 9:42 pm
by Bruce C
WordPress already assigns a special ID to each user. To find out how to get this: check this out:
codex.wordpress.org/Function_Reference/get_currentuserinfo

Re: setting a membership ID

PostPosted: October 20th, 2011, 2:12 am
by plumber
Thanks. Had a look at that already and am thinking I might construct a number from the wpuser array. Perhaps combine the date registered timestamp and the unique number. Problem I would have is storing them in the account or in the admin userlist as I may need an admin to be able to go in and export the list so that a mailmerge of sorts can be done tp print cards

That's my current line of thinking

Re: setting a membership ID

PostPosted: October 21st, 2011, 4:11 am
by plumber
Here's where I've got to so far (no idea if this is of interest to anyone else or not but thought I'd share what I've done anyway)

I've settled on a membership number of the format YYYYMMDDD-nnnnnn

I get the YYMMDD bit from the registration date of the user and the nnnnnn bit from the unique userid assigned by wordpress.

So a wee bit of PHP using strtotime and date to format the registration timestamp to pick out the YYYYMMDD part and a wee function to pad out the nnnnnn part with the correct number of leading zeroes.

I'm using the Headway theme which allows you to add PHP/HTML 'leafs' (Headway terminology not mine) so the php code can be dropped in without having to use any php exec plugins.

All of that is displayed dynamically to a logged in user only using s2If shortcode conditionals

What I now need to do is see if I can export these dynamically created membership numbers for card printing purposes. I've installed amr-users which is quite good at giving a gui type interface for user metadata in the admin dashboard - this includes all of the s2member stuff too and as it also allows export to CSV etc it is ideal for our purposes. I can set up a list with name, address, postcode, email etc, export it and then do a mailmerge for the cards.

the only snag I have is I can't (yet) see a way of applying the formatting for a membership number as used dynamically on the site. Might be able to do something in libreoffice excel though

it would all be so much simpler if there was a separate membership number field in s2members...

anyway - thanks to those who have offered advice and I hope this is maybe helpful to someone

I've included the code I used to strip out and format the data. Maybe someone will find it handy - or at least it might save a trip to the php manual...

Code: Select all
<?php

function number_pad($number,$n) {
return str_pad((int) $number,$n,"0",STR_PAD_LEFT);
}

?>
<?php
echo "Membership number: ";
echo date("Ymd", strtotime(get_userdata(get_current_user_id( ))->user_registered)); ?>

<?php
    global $userdata;
    get_currentuserinfo();
    echo "-" .  number_pad( $userdata->ID,6 );
?>

Re: setting a membership ID

PostPosted: October 21st, 2011, 7:40 am
by Eduan
Okay thanks, might come in handy!

Re: setting a membership ID

PostPosted: November 9th, 2011, 8:20 am
by ecowebdesign
Hello,
I am using the following code to display Member ID when users logs in:

<?php
global $userdata;
get_currentuserinfo();


echo 'MEMBER ID: GR-'. date('dmy', $regunixDate) ;
echo '-'. S2MEMBER_CURRENT_USER_ID;
?>

It is a junction form registration date & ID.
Which output like this: MEMBER ID: GR-150211-1

I would like to send this Member ID in the user registration e-mail, as i am doing with %user_login% or %user_pass%.

How it is possible ?

Re: setting a membership ID

PostPosted: November 11th, 2011, 1:52 am
by Cristián Lávaque
You could pass the current date in a custom value and then use it in the customized email. WP Admin -> s2Member -> PayPal Buttons -> Shortcode Attributes -> custom

Then in the custom New User email you can do something like GR-%%cv1%%-%%user_id%%. WP Admin -> s2Member -> General Options -> Email Configuration -> New User

I hope that helps. :)

Re: setting a membership ID

PostPosted: November 11th, 2011, 8:12 am
by ecowebdesign
Thank you so much Cristián !

It works !
Thumbs Up for s2 Member coding & support !

Re: setting a membership ID

PostPosted: November 12th, 2011, 2:22 am
by Cristián Lávaque
Excellent! Thanks for reporting back and the kudos! :)

Re: setting a membership ID

PostPosted: November 12th, 2011, 4:01 am
by plumber
Any plans for adding a membership number field? It seems such a basic and easy think to do. For those of us having to migrate from an existing manual system it would be really beneficial

Re: setting a membership ID

PostPosted: November 12th, 2011, 3:18 pm
by Cristián Lávaque
Doesn't a custom registration/profile field work for you to do this? WP Admin -> s2Member -> General Options -> Registration/Profile

Re: setting a membership ID

PostPosted: November 12th, 2011, 3:27 pm
by plumber
I don't want the user to be able to add or edit. can custom registration fields be hidden?

Re: setting a membership ID

PostPosted: November 12th, 2011, 3:47 pm
by Cristián Lávaque
When you create/edit the custom field, there's a setting titled "Allow Profile Edits". You can use that to remove the field from the person's profile.

To hide it from the registration form you can use CSS. viewtopic.php?f=4&t=14706

I hope that helps. :)

Re: setting a membership ID

PostPosted: November 13th, 2011, 5:20 pm
by plumber
That's worked perfectly thank you. Still a couple of tweaks to handle the CSS but it will do for now. It would be good if you could add the ability to hide custom registration fields in a future release though as it looks like I need to change login,css and any changes will be overwritten when wp is upgraded. Thanks for an elegant solution in the interim though

Re: setting a membership ID

PostPosted: November 15th, 2011, 1:36 am
by Cristián Lávaque
You're welcome. Glad I could help you. :)