• Hello

    I have a site where users can register for free. If they register for free they have to be able to upgrade to level 1. If upgrading they need to fill in some extra profile fields and then, without paying, upgrade to level 1.

    How can I accomplish this with s2member? I thought I could use the free register form, but this is only for register, not to upgrade a level.

    I bought s2member pro.

    Any help is appreciated!

    https://www.ads-software.com/plugins/s2member/

Viewing 10 replies - 1 through 10 (of 10 total)
  • Thread Starter raggarsoul

    (@raggarsoul)

    I found some sort of solution. https://www.s2member.com/kb/roles-caps-via-php/

    I made the following code in a separate plugin that I already was using for other template stuff. Maybe someone else can use this as well:

    if ( !defined( 'ABSPATH' ) ) exit;
    
    function crowd_change_role_from_xprofile($user_id, $posted_field_ids, $errors) {
    	if(bp_is_my_profile()){
    
    		if (xprofile_get_field_data('Field ID') == "field value" ) {
    
    			if(!is_admin() || !is_super_admin || current_user_is("subscriber")){
    				$user_id = get_current_user_id();
    				$user = new WP_User($user_id);
    				$old_user = unserialize(serialize($user));
    				$new_role = 's2member_level1';
    				$user->set_role($new_role);
    
    				do_action ('ws_plugin__s2member_during_collective_mods',
    				     $user_id, // The user's ID in WordPress?
    				     array(), // For debugging only. Use empty array here.
    				     'dynamic-user-role-change', // Role change flag.
    				     'modification', // A modification flag.
    				     $new_role, // New role.
    				     $user, // New user object instance.
    				     $old_user // Old user object instance.
    				);
    				fwrite($fp, xprofile_get_field_data('field ID'));
    				return;
    			}
    		}
    		elseif (xprofile_get_field_data('field ID') == "Field value" ) { 
    
    			if (!is_admin() || !is_super_admin || current_user_is("s2member_level1")){
    				$user_id = get_current_user_id();
    				$user = new WP_User($user_id);
    				$old_user = unserialize(serialize($user));
    				$new_role = 'subscriber';
    				$user->set_role($new_role);
    
    				do_action ('ws_plugin__s2member_during_collective_mods',
    				     $user_id, // The user's ID in WordPress?
    				     array(), // For debugging only. Use empty array here.
    				     'dynamic-user-role-change', // Role change flag.
    				     'modification', // A modification flag.
    				     $new_role, // New role.
    				     $user, // New user object instance.
    				     $old_user // Old user object instance.
    				);
    				return;
    			}
    			else {
    				return;
    			}
    		}
    		else {
    			return;
    		}
    	}
    }
    
    add_action( 'xprofile_updated_profile', 'crowd_change_role_from_xprofile', 1, 3);

    Hi,

    How do I create a simple function to upgrade current user from level 0 from level 1 with specified end of term date, plus a button/link for the current user in a page?

    many thanks.

    It’s really easy with s2member Pro forms. You can add the custom registration fields for level 1 users, use a membership upgrade form and set the cost to 0.

    I know there’s sometimes a hurdle with wanting to pay for plugin upgrades, but the pro forms are really great.

    <?php update_user_option( $user_id, "s2member_auto_eot_time", $theDate ) ?>
    this line of code should set your own expiration date. you need to provide it with a user id and the date though.

    haven’t tried it.

    I have a similar issue, I have a course that I sell and I am trying to give away a few copies for some people to test. I have done it in the past but now when I add a new user and click on the send new user login information they never get it and can’s login. I also tried to install the s2Member? Server Scanner but when I try it give me error message 404. Can anyone help?

    @jayneal: If you require assistance then, as per the Forum Welcome, please post your own topic instead of tagging onto someone else’s topic.

    the awesome server scanner link is broken.

    they tell you to test it with
    /s2-server-scan.php
    but the file you get from them is called:
    s2-server-scanner.php

    so try the server scanner with:
    https://yourwpadress/s2-server-scanner.php

    the 404 almost drove me insane…

    @natic86 Thanks the scanner worked

    Sorry @esmiTheme Diva & Forum Moderator I can’t figure out how to start one no where does it sat create a post or start a topic.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘upgrade to level 1 without paying’ is closed to new replies.