In Progress

Write some Software

I am working on a site that uses s2member pro. When a users membership expires the user is demoted to user level0. I need to know what level they were at prior to being demoted. s2member has a built in function which keeps track of all the user capabilities/roles which is stored in user_meta as an array:

$accessCaps = get_user_option('s2member_access_cap_times', $user_id);

The array is composed of a timestamp key and a value which contains the last level a user had prior to being demoted to level 0.

The problem is that the value in each key is stored as a natural number so level1 and level10 are sequential. (see output below)

Below is an example of the user meta from a user who was demoted to level 0:

foreach($accessCaps as $key => $value) { echo "$key is at $value<br>"; }

output:

(note:The user is created and assigned to level2)

1473730737.0001 is at level0

1473730737.0002 is at level1

1473730737.0003 is at level2 <--note: the user was added at this level and has access/capabilities of all lower levels

(note:The user is promoted to level5)

1473730847.0001 is at level3

1473730847.0002 is at level4

1473730847.0003 is at level5 <-- note: the user was promoted to this level and gets all lower levels as well

(note:The user is promoted to level11)

1473730986.0001 is at level10

1473730986.0002 is at level11 <-- note: The user was promoted to this level (you can see the sequential problem now because 10,11 are before 6,7,8,9)

1473730986.0003 is at level6

1473730986.0004 is at level7

1473730986.0005 is at level8

1473730986.0006 is at level9

(note:The user is demoted to level1)

1473731072.0001 is at -level1

1473731072.0002 is at -level10

1473731072.0003 is at -level11 <-- note: This is the last highest level, I need to get this value

1473731072.0004 is at -level2

1473731072.0005 is at -level3

1473731072.0006 is at -level4

1473731072.0007 is at -level5

1473731072.0008 is at -level6

1473731072.0009 is at -level7

1473731072.0010 is at -level8

1473731072.0011 is at -level9

What I need to do is this, get the last highest level that the user achieved, here's how I think it could be done:

Sort each key/value pair by time (as float point values), find the sub-array with the same integer part like the bigger timestamp in this case: 1473731072. Then sort this new array by values (levels) as natural numbers, to get the biggest level. (L11 in this case).

Please ask questions if you need clarification.

Thanks.

Skills: PHP, Regular Expressions, WordPress

See more: what did you have to do write about the following think of a business idea write a business plan and deliver a pitch chrome chro, software write mq4, software write chip epson, useful software write book, software write web specs, free software write user guide, software write edid, phpdl sort time, free software write company profile, software write websites idea, software write book images, software write books, software write protection, free software write book, software write book, real time pair trading software, software write protect software, software write technical manual, vbnet sort time

About the Employer:
( 8 reviews ) Hotchkiss, United States

Project ID: #11512580

Awarded to:

NickyJones

Hi. I have read your project description and this seems to be an easy task which can be done in hours. Ready to start. Thanks

$30 USD in 1 day
(1 Review)
0.0

3 freelancers are bidding on average $52 for this job

AVRocker1

Hello Client, I read your post regarding create logic for regex, I have great experience working with PHP technology it's CMS & Frameworks like YII, Laravel, Codeigniter, CakePHP, OpenCart, WordPress, Prestasho More

$30 USD in 1 day
(0 Reviews)
0.0
suniljoshi151

Hi, I can start work on your project immediately once you confirm me and i am also open for further discussion if you want. I have 7+ years in web designing & development with good experience in following skills More

$100 USD in 1 day
(0 Reviews)
0.0
ssmkalyan

A proposal has not yet been provided

$25 USD in 1 day
(0 Reviews)
0.0
rshahzaib786

Before awarding this to someone else contact me i have more than 8 year experience. Thanks

$30 USD in 3 days
(0 Reviews)
0.0