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.

Updating current user role & EOT via PHP

Home Forums Community Forum Updating current user role & EOT via PHP

This topic contains 5 replies, has 3 voices. Last updated by  Bruce 4 years, 1 month ago.

Topic Author Topic
Posted: Friday Nov 30th, 2012 at 10:15 am #33010
Max
Username: max_s

List Of Topic Replies

Viewing 5 replies - 1 through 5 (of 5 total)
Author Replies
Author Replies
Posted: Friday Nov 30th, 2012 at 4:39 pm #33045
Raam Dev
Username: Raam
Staff Member

Hi Max,

This thread has an example of a hack that manually updates the EOT field. You should be able to find what you need in the code there.

Posted: Monday Dec 3rd, 2012 at 6:49 am #33286
Max
Username: max_s

Thank you Raam for pointing me in the right direction! I was able to piece something together which works just fine.

<?php

if(($status = CheckReturnurl( $rtlo,  $_GET['trxid'] ))=="000000 OK" ){
    
    // CODE FOR AUTOMATICALLY UPDATING CURRENT USER'S ROLE & EOT GOES HERE
    
    update_user_option(get_current_user_id(), 's2member_auto_eot_time', strtotime('+3 months')); 
    $user = new WP_User(get_current_user_id());
    $user->set_role("s2member_level2");

    echo "Thanks for renewing your membership!";

    c_ws_plugin__s2member_user_notes::append_user_notes (get_current_user_id(), "Renewed on: " . date ("D M j, Y g:i a T"));	
    
  }
 
 // IF PAYMENT UNSUCCESSFUL, STATUS REPLIED HERE
  
  else die( $status );

}

?>

The only thing that doesn’t work is appending a note upon renewal. Any thoughts?

Thanks!

Posted: Monday Dec 3rd, 2012 at 2:12 pm #33340
Bruce
Username: Bruce
Staff Member

Hi Max,

The only thing that doesn’t work is appending a note upon renewal. Any thoughts?

Try formatting your code like this:

<?php
if(($status = CheckReturnurl( $rtlo,  $_GET&#91;'trxid'&#93; )) === '000000 OK') {
	global $current_user;
	$user = new WP_User($current_user->ID);
	
	update_user_option($user->ID, 's2member_auto_eot_time', strtotime('+3 months'));
	if(!current_user_can('administrator')) // Added this to ensure that you do not end up getting locked out during testing
		$user->set_role("s2member_level2");
	c_ws_plugin__s2member_user_notes::append_user_notes (get_current_user_id(), "Renewed on: " . date ("D M j, Y g:i a T"));	
	echo "Thanks for renewing your membership!";

  }
 
 // IF PAYMENT UNSUCCESSFUL, STATUS REPLIED HERE
 	else die( $status );

}
Posted: Monday Dec 3rd, 2012 at 4:06 pm #33363
Max
Username: max_s

Great! That did the trick :)

Thanks for the support!

Posted: Monday Dec 3rd, 2012 at 4:13 pm #33365
Bruce
Username: Bruce
Staff Member

Glad to hear it fixed the issue.

Viewing 5 replies - 1 through 5 (of 5 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.