This topic has 41 replies, 15 voices, and was last updated 8 years by Abe.

  • Author
  • #2204
     jaybini
    Participant

    After a user registers, How can I make the user apply automatically in a specific membership plan ?

    #2216
     Harvinder
    Participant

    Yes I would like to do the same.

    When a user registers they are automatically in the “Free” membership level.

    Then they have the option to upgrade.

    #2261
     SQadmin
    Keymaster

    Hi,
    We’ll look into it. You could just not create the FREE level and assume it as free if a user hasn;t applied for a level

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #2263
     Harvinder
    Participant

    Hi,

    Yes I could do that but then I don’t have the option to restrict functionality as they are not in a level?

    #2275
     SQadmin
    Keymaster

    Yes you do have the option in Membership -> Advanced to check Logged in or Not Member(this is a user that hasn’t subscribed)

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #2294
     Harvinder
    Participant

    Ok, thanks for this that is great.

    #2727
     SQadmin
    Keymaster

    Hi,
    This is the function you need to add in order to assign a specific membership level to a newly registered user. Add it into your sweetdate-child/functions.php

    COPY CODE
    
    
    add_action('user_register', 'kleo_pmpro_default_level');
    function kleo_pmpro_default_level($user_id) {
    	pmpro_changeMembershipLevel(1,$user_id);
    }
    

    This one assigns level with ID 1

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #5411
     SQadmin
    Keymaster

    Also this code checks for a specific profile value and add only those users to the membership level:

    COPY CODE
    
    
    
    /**
    * When registering, add the member to a specific membership level
    * based on the field value he has selected
    *
    * @global object $wpdb
    * @global object $bp
    * @param integer $user_id
    */
    function kleo_pmpro_default_level($user_id) {
        global $wpdb, $bp;
     
        //Change this with your field name
        $field_name= "I am a";
     
        //Change the field value
        $value_to_match = "Woman";
     
        //Membership level id
        $membership_level = 1;
     
        //Done editing
        $field_id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->profile->table_name_fields} WHERE name = %s", $field_name ) );
        if ($_POST['field_'.$field_id] == $value_to_match) {
                pmpro_changeMembershipLevel($membership_level, $user_id);
        }
    }
     
    function kleo_mu_pmpro_default_level($user_id, $password, $meta) {
        global $bp, $wpdb;
     
        //Change this with your field name
        $field_name= "I am a";
     
        //Change the field value
        $value_to_match = "Woman";
     
        //Membership level id
        $membership_level = 1;
     
        
        //Done editing
        $field_id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->profile->table_name_fields} WHERE name = %s", $field_name ) );
        $field_value = $meta['field_'.$field_id];
        if ( $field_value == $value_to_match ) {
            pmpro_changeMembershipLevel($membership_level, $user_id);
        }
    }
     
    if (is_multisite()) {
        add_action( 'wpmu_activate_user', 'kleo_mu_pmpro_default_level', 10, 3);
    } else {
        add_action('user_register', 'kleo_pmpro_default_level');
    }
    
    
    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #5865
     djtreble12
    Participant

    How do i fix the last code listed above? (checks for a specific profile value and add only those users to the membership level)

    when i add it i get a blank white screen i dont think its closed….. when i remove the code the site works correctly

    #5867
     JohnDoe
    Participant

    How to add ur second code so i give men for example the free ID automaticly , and woman a different ID

    #5885
     dlcjonathan
    Participant

    i get the blank white screen too…can you explain how to make this work. thanks

    #5908
     SQadmin
    Keymaster

    The code will be something like:

    COPY CODE
    
    
    function kleo_pmpro_default_level($user_id) {
    	global $wpdb, $bp;
    	
    	//Change this with your field name
    	$field_name= "I am a";
    	
    	//Change the field value
    	$value_to_match = "Woman";
    	
    	//Membership level id
    	$membership_level = 1;
    	
    	//Done editing
    	$field_id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->profile->table_name_fields} WHERE name = %s", $field_name ) );
    
    	if ($_POST['field_'.$field_id] == $value_to_match) {
    		pmpro_changeMembershipLevel($membership_level, $user_id);
    	} elseif ($_POST['field_'.$field_id] == "Man") {
    pmpro_changeMembershipLevel(OTHER_LEVEL_ID, $user_id);
    }
    }
    add_action('user_register', 'kleo_pmpro_default_level');
    
    
    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #5909
     SQadmin
    Keymaster

    If you are getting the blank screen then you are not copying the whole code

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #5955
     JohnDoe
    Participant

    And , how do i give my users that allready registered free user to all now? cos all my other registered users got no membership .

    #6019
     SQadmin
    Keymaster

    Manually from Membership – Members 🙂

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #6023
     JohnDoe
    Participant

    no , that only shows the people who allready have a membership ID , i want to make people without a memberships ID to a Free user , ID 2

    #6032
     SQadmin
    Keymaster

    Oh. you are right 🙂
    I meant Users – Edit user – Set membership there

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #6036
     JohnDoe
    Participant

    O , alot of work.. :p but if that is what it takes, then let’s go! :p lucky i didn’t have a big database yet .. i read something btw like this :

    Ok , so running this sql query works on my local setup:

    SELECT * FROM wp_users WHERE 1;
    UPDATE wp_users SET user_level=’2′;

    To actually edit the users table in phpmyadmin

    #12760
     harryshapes
    Participant
    This reply has been set as private.
    #12901
     Abe
    Keymaster

    @harryshapes Level id’s start from number 1 and you see the id in Memberships – Levels. That id that you want to assign to female members you need to change in that code

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    ---
    @ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.

    #13913
     Steven
    Participant

    Hi All, ( specially Robert for your Code above ) I am trying to create a website where only men have to pay for any membership, while women get free access and all functions. Is there a way I can just charge men for all levels of memberships, and not charge women for anything? I would really appreciate anyone’s help with this matter please and if you could tell me a little on how to do this as my coding skills are very limited.

    Thanks,

    Steve

    #14080
     Abe
    Keymaster

    Hi, The code from this post does just that. https://archived.seventhqueen.com/forums/topic/membership-auto-in-registration/#post-5411

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    ---
    @ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.

    #14092
     Steven
    Participant

    Hi Robert, thanks, I got the women free part, how about men cannot see other mens profile, is this possible please? Its like a confidential thing between men. If they purchase a premium package, then they may see other mens profile, but for a free membership, I would love if its possible not to allow this.

    #14169
     Abe
    Keymaster

    Hi, That is not achievable with the default functionality but can be done only with some custom code that you have to develop. If you do not have programming knowledge you can hire a developer from sites like microlancer.com

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    ---
    @ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.

    #14451
     dojoge
    Participant

    I would like to send users to the membership levels page immediately after registration. Is this possible?

    #14712
     Abe
    Keymaster

    Hi, There are plenty resources out there. See: http://wordpress.stackexchange.com/questions/18301/redirect-after-registration-in-buddypress

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    ---
    @ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.

    #14819
     salsero
    Participant

    where I paste the code

    #15051
     Abe
    Keymaster

    It says that you have to put it in sweetdate-child/functions.php That is on your server in wp-content/themes

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    ---
    @ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.

    #42550
     mlennox10
    Participant

    Hi there,

    I’ve tried to follow this thread but cannot find the setting described above.

    Yes you do have the option in Membership -> Advanced to check Logged in or Not Member(this is a user that hasn’t subscribed)

    To be clear, my site is a FREE site (but only for members). So when a user registers and is approved, I want them to have access to all areas of the site. But when a non-member or not-logged-in member, visits my site I want to restrict the forum, member viewing etc.

    All help would be really appreciated and i’m running KLEO.

    Thanks

    #43030
     Abe
    Keymaster

    Then you don’t need a membership plugin @mlennox10
    but maybe a plugin like: https://wordpress.org/plugins/buddypress-members-only/

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    ---
    @ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.

    #43072
     mlennox10
    Participant

    Thanks @abe but as far as I can see that locks my whole site down. I want to draw members in through the blog and events, but commenting and forum participation are locked down.

    As above, can you tell me what you meant by this:

    “Yes you do have the option in Membership -> Advanced to check Logged in or Not Member(this is a user that hasn’t subscribed)”

    Because that’s what I’m after..

    #43473
     Abe
    Keymaster

    Then you can install paid memberships pro but don’t configure any membership levels and just configure our restrictions to buddypress from Sweetdate – Memberships

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    ---
    @ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.

    #45097
     tdarnold
    Participant

    I copied the code to functions,php but am getting an error message and can see the code at the top when logged in. I know absolutely nothing about php but am thinking it has to do with a closing tag. around the code

    #45098
     tdarnold
    Participant

    Found the problem. I see now where the code should be inserted before the php closing tag.

    #60341
     harryshapes
    Participant

    Hi,

    Tried to use the code above and I am not sure if its because things have been updated since the code was given but now when pasting it fully into the functions.php section of the theme it shows the code at the top of the website with a white background and my website underneath..

    please advise.. thanks a lot!

    #61477
     Abe
    Keymaster

    @harryshapes you probably have a typo in your code. you need basic php knowledge for that. try to inspect the code and make sure is copied ok

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    ---
    @ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.

    #66258
     gagdiversion
    Participant
    This reply has been set as private.
    #67551
     Abe
    Keymaster

    @gagdiversion
    please open a new topic since it is now related to this discussion

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    ---
    @ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.

    #95391
     gugga7
    Participant

    Hello, is this code still accurate? I copied it in functions.php for the Child theme, I changed the membership level ID but nothing happens when a new user registers.

    COPY CODE
    add_action('user_register', 'kleo_pmpro_default_level');
    function kleo_pmpro_default_level($user_id) {
    	pmpro_changeMembershipLevel(1,$user_id);
    }
    #95507
     Abe
    Keymaster

    yes that code should work when users register.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    ---
    @ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.

Viewing 40 posts - 1 through 40 (of 42 total)

You must be logged in to reply to this topic.

Log in with your credentials

Forgot your details?