• Resolved Mauro Mello

    (@mauromello)


    The plugin uses phone number stored in WP user profile. But using buddypress users don’t need access to the backend. Is there a way to use a xprofile field as events manager phone number? Or a way to sync xprofile phone number field to dbem_phone?

    Thanks!

    PS: Using latest versions of events manager, BP and WP

    https://wordpress.org/plugins/events-manager/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Support angelo_nwl

    (@angelo_nwl)

    it’s not possible out the box at the moment. it may be possible with custom coding but unfortunately that’s not something we can help with.

    Thread Starter Mauro Mello

    (@mauromello)

    OK. I’m not good at custom coding… 🙂 But I’m looking for a way to keep fields synched. I’ll post here if find anything.

    Thanks @angelo_nwl

    Thread Starter Mauro Mello

    (@mauromello)

    Hi! I was able to make it happen with code below inside child-teme function.php:

    function sync_xprofile_to_user_meta_one_way_only(){
    
    	$user_id = get_current_user_id();
    
    	$em_telefone = xprofile_get_field_data( "XPROFILE_PHONE_FIELD_NAME" ,$user_id);
    	update_user_meta( $user_id, 'dbem_phone', $em_telefone);
    }
    
    add_action( 'xprofile_updated_profile', 'sync_xprofile_to_user_meta_one_way_only', 10, 0 );
    add_action( 'bp_core_signup_user', 'sync_xprofile_to_user_meta_one_way_only', 10, 0 );
    add_action( 'bp_core_activated_user', 'sync_xprofile_to_user_meta_one_way_only', 10, 0 );

    Thanks for sharing your code; it might help someone else.

    Hugo64

    (@hugobernard)

    Hello @mauromello,

    Nice! that’s just what I need. But your phone field is XPROFILE_PHONE_FIELD_NAME ??

    And how do you check it’s working? through the wordpress profile field or through an em action (like sending new booking email to admin)…

    Thanks in advance.

    Hugo

    • This reply was modified 7 years, 7 months ago by Hugo64.
    Thread Starter Mauro Mello

    (@mauromello)

    Hi @hugobernard

    XPROFILE_PHONE_FIELD_NAME is just a generic name. You should use your field name.
    I just checked once looking user profile to check it’s working. But you can improve it writing to log or any other action you like…

    Let me know if you improve this code…

    • This reply was modified 7 years, 7 months ago by Mauro Mello.
    • This reply was modified 7 years, 7 months ago by Mauro Mello.
    Hugo64

    (@hugobernard)

    Hey @mauromello,

    Thanks for answering, I put it and nothing happened. my field name is “Movil”. Maybe should I put something else I don’t know. Working on it… but if you have an idea… 😉

    Cheers

    Thread Starter Mauro Mello

    (@mauromello)

    @hugobernard

    Below is my full code

    function sync_xprofile_to_user_meta_one_way_only(){
    	
    	
    	$user_id = get_current_user_id();
    	$bp_telefone = xprofile_get_field_data( "Telefone" ,$user_id);
    	$bp_whatsapp = xprofile_get_field_data( "Whatsapp" ,$user_id);
    		
    	if (!empty($bp_whatsapp)) : 
    		$em_telefone = $bp_telefone . ' / ' . $bp_whatsapp;
    	else :
    		$em_telefone = $bp_telefone;
    	endif;
    	
    	update_user_meta( $user_id, 'dbem_phone', $em_telefone);
    }
    
    add_action( 'xprofile_updated_profile', 'sync_xprofile_to_user_meta_one_way_only', 10, 0 );
    add_action( 'bp_core_signup_user', 'sync_xprofile_to_user_meta_one_way_only', 10, 0 );
    add_action( 'bp_core_activated_user', 'sync_xprofile_to_user_meta_one_way_only', 10, 0 );

    I don’t know why, but looks like only the ‘xprofile_updated_profile’ action is working… Try to update the profile and check if the field is updated..

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Use Phone Number from BuddyPress XProfile Field’ is closed to new replies.