BuddyDev

Search

[Resolved] BP Username Changer plugin & WordPress or BuddyBoss triggers in AutomatorWP

  • Participant
    Level: Enlightened
    Posts: 26
    Mark Winstein on #42498

    I use your BuddyPress Username Changer plugin to allow members to change their Usernames.

    I also use AutomatorWP to update my external email list when members take certain action in our BuddyBoss membership site.

    Currently, a frontend Username update via the BuddyPress Username Changer plugin does not result in a User Meta update automation trigger that AutomatorWP can use to fire an automation.

    The tech at AutomatorWP proposed I request that BuddyDev adjust the plugin to trigger off of the Username change event as follows…

    “The WordPress trigger is designed to only work when the WordPress standard event is triggered (basically, when you update the user data from the default WordPress user edit screen).

    If the user updates this information from some custom screen (like in the frontend) and this custom way does not trigger the WordPress event, AutomatorWP will not detect it.

    For your case, you can ask the add-on authors if there is way they can trigger the “profile_update” event that triggers WordPress when a user account field gets updated.”

    What do you think? Can you do this either as a free update or custom work?

    Thank you very much.
    Mark

  • Keymaster
    (BuddyDev Team)
    Posts: 24190
    Brajesh Singh on #42504

    Hi Mark,
    thank you.

    Please tell them that we are using “wp_update_user” function to update the username. So, the relevant actions should fire automatically. They should check if they have some limitations that this is happening inside the admin.

    and please link them to this
    https://github.com/sbrajesh/bp-username-changer/blob/master/bp-change-username.php#L157

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 26
    Mark Winstein on #42508

    Will try and let’s see what they say back! Thank you!

  • Keymaster
    (BuddyDev Team)
    Posts: 24190
    Brajesh Singh on #42533

    Thank you.

    Please do let me know their response.

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 26
    Mark Winstein on #42630

    Hi Brajesh,

    They are trying to make an updated version, but currently it causes my site to pull a critical error when a user updates their username with your plugin.

    I would like to see if you could help me with a simpler approach. Is there a code-snippet function you could provide me to send a webhook when the username is updated that would contain the new UserID and new Username in the payload?

    Thanks again,
    Mark

  • Keymaster
    (BuddyDev Team)
    Posts: 24190
    Brajesh Singh on #42636

    Hi Mark,
    I am sorry about that.

    We are already providing a hook that contains the new username and the user object.
    Here is the code we have put there.

    
    do_action( 'bp_username_changed', $new_user_name, $bp->displayed_user->userdata, $user );
    

    As far as sending this data via webhook is concerned, I am sorry, that can not be accomplished in couple of lines as there are security and other considerations. If you are using a plugin that has some api for sending random data, I can assit.

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 26
    Mark Winstein on #42643

    Hi Brajesh,

    1) The update sounds great. Is this available via the github? When will I be able to update my site with it?

    2) If you could provide a code snippet that only returns the User ID number after the plugin updates that user’s Username, I can securely handle the rest of the coding myself.

    Thanks again,
    Mark

  • Keymaster
    (BuddyDev Team)
    Posts: 24190
    Brajesh Singh on #42648

    Hi Mark,

    1. That code is already part of the plugin.
    2. Here is an example.

    
    add_action( 'bp_username_changed', function ( $new_username, $data, $user ) {
    
    	$user_id = $user->ID;
    
    }, 10, 3 );
    
    

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 26
    Mark Winstein on #42658

    I tried the following. As far as I can tell, this is not executing when a logged-in user updates via the interface provided by the plugin. I copied all the code underneath $user_id from a prior snippet I wrote that worked fine.

    Any thoughts??

    
    add_action( 'bp_username_changed', function ( $new_username, $data, $user ) {
    
            $user_id = $user->ID;
      
    	    // Send ID to AutomatorWP trigger
    		$url = 'https://XXXXXX';   
    		$response = wp_remote_post( $url, array(
    			'method'      => 'POST',
    			'timeout'     => 45,
    			'redirection' => 5,
    			'httpversion' => '1.0',
    			'blocking'    => true,
    			'headers'     => array(),
    			'body'        => array(
    			  'ID' 	      => $user_id
    			 ),
    			'cookies'     => array()
    		  )
    		);		  
    
    }, 10, 3 );
    
    
  • Participant
    Level: Enlightened
    Posts: 26
    Mark Winstein on #42659

    Sorry – tested another way, your code works fine! Thank you!

The topic ‘ [Resolved] BP Username Changer plugin & WordPress or BuddyBoss triggers in AutomatorWP’ is closed to new replies.

This topic is: resolved