latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Add note on registration + EOT date format

Home Forums Community Forum Unofficial Extensions/Hacks Add note on registration + EOT date format

This topic contains 7 replies, has 3 voices. Last updated by  Cristián Lávaque 4 years, 2 months ago.

Topic Author Topic
Posted: Tuesday Nov 6th, 2012 at 12:38 pm #30780

Hi,

Have been working with S2Member for a while now, and VERY nearly got to where we need to be! Two more questions before we do:

1. How can I automatically add an entry to a user’s notes (containing user level) when they register? (OR how do I record the previous membership level in notes when they are automatically demoted at EOT – I’ve seen this method http://www.s2member.com/forums/topic/bugs-profile-edits-new-users-downgrades/#post-17911, but wary of replicating whole classes over to MU plugins, in case they change in future…)

2. How can I change EOT field date format, to allow UK-style date input (i.e. dd/mm/yyyy rather than mm/dd/yyyy)?

Many thanks in advance!
Sarah

  • This topic was modified 4 years, 2 months ago by  Cristián Lávaque. Reason: Moved to the User Hacks forum

List Of Topic Replies

Viewing 7 replies - 1 through 7 (of 7 total)
Author Replies
Author Replies
Posted: Wednesday Nov 7th, 2012 at 7:38 am #30866

Hi Sarah.

1. How can I automatically add an entry to a user’s notes (containing user level) when they register? (OR how do I record the previous membership level in notes when they are automatically demoted at EOT – I’ve seen this method http://www.s2member.com/forums/topic/bugs-profile-edits-new-users-downgrades/#post-17911, but wary of replicating whole classes over to MU plugins, in case they change in future…)

As long as after an s2Member update you check if there’s anything different in that file and update your customized copy if needed, it’d be fine.

2. How can I change EOT field date format, to allow UK-style date input (i.e. dd/mm/yyyy rather than mm/dd/yyyy)?

The EOT field’s description when clicking the [?] link, says regarding the format:

anything compatible with PHP’s strtotime() function.

And the documentation for strtotime says:

Dates in the m/d/y or d-m-y formats are disambiguated by looking at the separator between the various components: if the separator is a slash (/), then the American m/d/y is assumed; whereas if the separator is a dash (-) or a dot (.), then the European d-m-y format is assumed.

To avoid potential ambiguity, it’s best to use ISO 8601 (YYYY-MM-DD) dates or DateTime::createFromFormat() when possible.

So you can do [hilite mono]dd-mm-yyyy[/hilite].

I hope that helps. :)

Posted: Wednesday Nov 7th, 2012 at 7:46 am #30868

Hi Cristian,

Thanks for your help!

Re. 1 – I should have been more clear – the reason I’m wary of copying whole classes over to MUplugins is that I have lots of client websites to maintain, so if at all possible, I try and avoid anything that requires manual checking/upgrading at a later point. Is there any other way to add a user note, when the user account is first created and when the account type is changed?

2 – Thanks – I hadn’t realised the distinction between the two types of separator, that’s great!

Sarah

Posted: Wednesday Nov 7th, 2012 at 9:21 am #30894

I try and avoid anything that requires manual checking/upgrading at a later point. Is there any other way to add a user note, when the user account is first created and when the account type is changed?

Of course, I can understand that.

Well, it can be done if you use WP hooks, but I didn’t see one available to do this hack on EOT. There may be one available on user creation/editing, though. Maybe this one? http://adambrown.info/p/wp_hooks/hook/set_user_role

Posted: Wednesday Nov 7th, 2012 at 12:40 pm #30921

Thanks for the pointer… for anyone else that might be looking to do the same thing:

add_action( 'set_user_role', 'add_role_change_note', 10, 2);

function add_role_change_note( $user_id, $new_role ) {
  c_ws_plugin__s2member_user_notes::append_user_notes ($user_id, "User role created as/changed to " . $new_role .': '. date ("D M j, Y g:i a T"));
}

Note this appends the note to user record when added via S2Member, demoted via S2Member, or edited in wp-admin. It doesn’t add the note when the user is added via wp-admin.

Posted: Wednesday Nov 7th, 2012 at 6:57 pm #30954
Raam Dev
Username: Raam
Staff Member

Thank you so much for sharing that, Sarah!

Awarded Sarah the Helpful badge.
Posted: Thursday Nov 8th, 2012 at 9:47 am #31030

Thanks Raam :o)

Posted: Friday Nov 9th, 2012 at 3:43 am #31102

Nice! Thanks for sharing it. :)

I moved the thread to the Hacks forum.

Viewing 7 replies - 1 through 7 (of 7 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.