Skip to:
Content
Pages
Categories
Search
Top
Bottom

Setting profile fields automaticly


  • talooz
    Participant

    @talooz

    Hello everyone!

    I am trying to make some fields to be filled as user registers to my site.

    My goal is to make this condition:
    if [gender=male] then [interested_in=female]
    if [gender=female] then [intersted_in=male]

    i have written a code for that and applied it on my functions.php file and add_action to user_registration. but no luck so far.
    this is my code:

    function changeinterest( $user_id ) {
    			$args = array(
    		    'field'     => 'My_Gender',
    		    'user_id'   => $user_id
    		);
    		$field_name = 'My_Interests';
    		$original = bp_profile_field_data($args);
    		$value = maybe_serialize('male');
    		$femalevalue = maybe_serialize('female');
    		
    if ($original = 'female') { xprofile_set_field_data( $field_name, $user_id, $value);}
    elseif( $original = 'male' ){xprofile_set_field_data( $field_name, $user_id, $femalevalue);};
    }
    add_action( 'user_register', 'changeinterest', 10, 1 );

    To me it seems correct and written ok, but I cannot understand why it’s not working.
    any help would be much much much appreciated !!

  • The topic ‘Setting profile fields automaticly’ is closed to new replies.
Skip to toolbar