This topic has 12 replies, 2 voices, and was last updated 6 years by tulipwork.

  • Author
  • #205447
     tulipwork
    Participant

    Hello,

    I added this snippet to the functions.php of my website allowing women a free access via the VIP membership level (1).

    The problem is that women who register via Facebook registration don’t benefit from the snippet: after the registration, they have to choose a membership level and if they choose the level (1), they have to pay.

    How to automatically affect the level (1) to women who register via Facebook in order to give them the free access, like the other women who register via the classic registration?

    Thanks.

    #205452
     Kieran_SQ
    Moderator

    Hi,

    I have logged into your site but I do not see any custom code in your functions.php file. Please try this updated snippet and let me know if this works for you or not. Remember that you will need to update this code with the correct membership level that you wish to assign.

    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');
        add_action('fb_register_action', 'kleo_pmpro_default_level');
    }

    Kieran

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

    If you like the theme or the support you've received please consider leaving us a review on Themeforest!

    Custom development requests can be sent to dev@seventhqueen.com, one of the development team will be happy to discuss your needs.

    #205457
     tulipwork
    Participant

    Hi,

    Sorry, the custom code is inside the Custom Function plugin:
    /wp-admin/options-general.php?page=my-custom-functions

    Thanks for your support

    #205458
     Kieran_SQ
    Moderator

    Hi,

    I have added the amended code to line 53. Please can you check this works from the desktop browser and let me know.

    Purge website cache, CDN and browser cache before trying to register again via Facebook.

    Kieran

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

    If you like the theme or the support you've received please consider leaving us a review on Themeforest!

    Custom development requests can be sent to dev@seventhqueen.com, one of the development team will be happy to discuss your needs.

    #205470
     tulipwork
    Participant

    Hi,

    It’s unfortunately not working: when I registered via Facebook, I’m redirected to the profile page and BuddyPress invites me to fill profile fields. Whatever gender I choose, “male” or “female”, my profil doesn’t have any membership level.

    With classic registration and custom function, the male has “free member” level (3) on the registration, and the woman as “VIP member” (1) for free.

    Thanks for helping.

    #205472
     Kieran_SQ
    Moderator

    Hi,

    I see the issue now, I thought it was because of the lacking Facebook register action. When a user registers via Facebook we take the name, email and profile picture of the user – we do not process their gender so there is no way for the default code to know whether they’re male or female.

    If you wanted to include this you would need to extend the code we already provide for Facebook to suit your needs, install a plugin that can handle that data or a hire a developer to achieve this for you. Then you can extend the custom snippet we provided and run your own action within it.

    I believe also that Facebook will require more information from you with regards to enabling getting the users gender.

    Thanks,

    Kieran

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

    If you like the theme or the support you've received please consider leaving us a review on Themeforest!

    Custom development requests can be sent to dev@seventhqueen.com, one of the development team will be happy to discuss your needs.

    #205475
     tulipwork
    Participant

    Ok I see.

    Is it possible to do it easier: block the gender after the user has chose one on registration, and block it also after profile editing for users who have registered via facebook.

    And then, when the user has chose his gender (on registration or on profile edit), a membership level is affected to him or her, according the gender.

    Is it possible to have a snippet for this?

    #205477
     Kieran_SQ
    Moderator

    Hi,

    The snippet provided is for on registration and would need wholly reworked to account for profile field changes after the user is registered. This is outside the scope of the support offered with the theme and is considered custom development.

    There is only one plugin that I currently know of, Advanced XProfile Fields for BuddyPress, that would achieve the non-editable profile field but that plugin is two years out of date. If you were unable to petition the developer to update their plugin then this would need to be coded in too.

    The link to the plugin is https://wordpress.org/plugins/advanced-xprofile-fields-for-buddypress/.

    If you would like to speak to our dev team about custom development then please feel free to email dev@seventhqueen.com with as much information as possible and someone will be in touch shortly.

    Thanks,

    Kieran

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

    If you like the theme or the support you've received please consider leaving us a review on Themeforest!

    Custom development requests can be sent to dev@seventhqueen.com, one of the development team will be happy to discuss your needs.

    #205483
     tulipwork
    Participant

    Mmh ok I see!
    There is no way to display different memberships levels to choose according gender of the user?

    #205484
     Kieran_SQ
    Moderator

    Hi,

    Again this would take custom code to manipulate the output of available membership packages. It’s definitely doable but you would need to build this yourself or hire a developer as it’s not part of the theme or the plugin. You’d need to get the current user, check their profile fields and then only return X packages for female and and else for male (depending which type of user was free).

    Kieran

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

    If you like the theme or the support you've received please consider leaving us a review on Themeforest!

    Custom development requests can be sent to dev@seventhqueen.com, one of the development team will be happy to discuss your needs.

    #205488
     tulipwork
    Participant

    OK thank you very much! I’m going to disable Facebook registration for now.
    Thank you very much for your help and great support!

    #205489
     Kieran_SQ
    Moderator

    Hi,

    Okay, sorry I couldn’t be of more assistance on the custom requests. We’re very happy to help with any theme issues or questions you may have so please do feel free to open a new ticket anytime.

    All the best,

    Kieran

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

    If you like the theme or the support you've received please consider leaving us a review on Themeforest!

    Custom development requests can be sent to dev@seventhqueen.com, one of the development team will be happy to discuss your needs.

    #205490
     tulipwork
    Participant

    No problem!

Viewing 13 posts - 1 through 13 (of 13 total)

You must be logged in to reply to this topic.

Log in with your credentials

Forgot your details?