-
Author
-
August 5, 2018 at 13:29 #205447tulipworkParticipant
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.
August 5, 2018 at 15:54 #205452Kieran_SQModeratorHi,
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 solutionIf 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.
August 5, 2018 at 16:24 #205457tulipworkParticipantHi,
Sorry, the custom code is inside the Custom Function plugin:
/wp-admin/options-general.php?page=my-custom-functionsThanks for your support
August 5, 2018 at 16:27 #205458Kieran_SQModeratorHi,
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 solutionIf 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.
August 5, 2018 at 17:31 #205470tulipworkParticipantHi,
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.
August 5, 2018 at 17:36 #205472Kieran_SQModeratorHi,
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 solutionIf 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.
August 5, 2018 at 18:16 #205475tulipworkParticipantOk 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?
August 5, 2018 at 18:22 #205477Kieran_SQModeratorHi,
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 solutionIf 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.
August 5, 2018 at 19:11 #205483tulipworkParticipantMmh ok I see!
There is no way to display different memberships levels to choose according gender of the user?August 5, 2018 at 19:16 #205484Kieran_SQModeratorHi,
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 solutionIf 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.
August 5, 2018 at 20:39 #205488tulipworkParticipantOK thank you very much! I’m going to disable Facebook registration for now.
Thank you very much for your help and great support!August 5, 2018 at 20:44 #205489Kieran_SQModeratorHi,
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 solutionIf 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.
-
AuthorPosts
You must be logged in to reply to this topic.