How to Integrate s2Members and BuddyPress Registration?
-
Hi!
I am using WordPress 4.8.3, BuddyPress 2.9.2, and s2Member 170722
at http://gatetest2.aishasalem.comI am doing everything that I can to integrate BuddyPress and s2Memeber.
I am hoping to get a smooth registration process going. With a free membership and a paid membership, s2member_level1. It seems no matter what I do, the registration process is ugly, and they don’t really talk to each other.
Currenlty, I am trying the code out from this post https://codex.buddypress.org/developer/user-submitted-guides/useful_func_s2_bp/. It seems very promising. I have modified the code a little AND had to add some code to disable the buddypress automatic redirect from the default wordpress registration page.
Here is my code (slightly modified from the one in the post, as I want to add this for all members, not just level2).
// disable BuddyPress redirect from default reg page function my_disable_bp_registration() { remove_action( 'bp_init', 'bp_core_wpsignup_redirect' ); // remove_action( 'bp_screens', 'bp_core_screen_signup' ); } add_action( 'bp_loaded', 'my_disable_bp_registration' ); add_filter( 'bp_get_signup_page', "firmasite_redirect_bp_signup_page"); function firmasite_redirect_bp_signup_page($page ){ return bp_get_root_domain() . '/wp-signup.php'; } // Function to populate BP Profile Fields w/ S2member Fields. add_action('wp_login','s2_profile_field_update',10,2); function s2_profile_field_update() { global $current_user; //Array of xprofile field names $xprofile_fields = array('Last Name','Country','Introduce yourself to Aisha Salem'); //Array of s2member field slugs $s2member_fields = array('last_name','user_country','member_letter_aisha'); //Populates BP with S2 info get_currentuserinfo(); // if( current_user_is("s2member_level1") ) { for($i = 0; $i < sizeof($xprofile_fields); $i++) { if(xprofile_get_field_data($xprofile_fields[i], $current_user->id) == '' && get_user_field($s2member_fields[i]) != '' ) { xprofile_set_field_data($xprofile_fields[i], $current_user->id, get_user_field($s2member_fields[i]) ); } } // } }
After this, nothing has really changed. I am not sure about the details.
Like:- Where exactly do I get the xprofile field names?
- Where exactly do I get the s2Member field slugs?
- Do I need to create these custom fileds with the same names in both BuddyPress and s2Members? (Which is what I have tried, so I am guessing no, or I am just doing it wrong…)
So, as I understand it, with this code. I use the s2Member registration process and the next time the user loggs in, it is updated to their BuddyPress profile.
Please let me know if I am not understanding this. AND PLEASE help me to understand how to do this correctly.
Thank you so much!
- You must be logged in to reply to this topic.