Skip to:
Content
Pages
Categories
Search
Top
Bottom

Geting input values in Edit Profile page

  • @rchiriac

    Participant

    Hello,

    Is it possible to get the values of the input fields from the members’ profile Edit Page?

    I found the HTML under mythemename/members/single/profile/edit.php but whenever the user hits “Save changes” I would like to read all the POST values (First name, Last name, City, Newsletter etc) so I can send them to an external API I use.

    So where’s the function that UPDATEs these values to the database?
    Thanks.

Viewing 6 replies - 1 through 6 (of 6 total)
  • @shanebp

    Moderator

    use this hook:
    do_action( 'xprofile_updated_profile', bp_displayed_user_id(), $posted_field_ids, $errors );

    found in:
    buddypress\bp-xprofile\bp-xprofile-screens.php L. 125

    @rchiriac

    Participant

    Thanks @shanebp but I’m fairly new to WP and BP. This is what I do:

    1. edit.php: At the end of file just after “do_action( ‘bp_after_profile_edit_content’ );”
    I’m adding your line:
    do_action( 'xprofile_updated_profile', bp_displayed_user_id(), $posted_field_ids, $errors );

    2. functions.php:

    function hook_bp_profileupdate( $ids, $errors ) {
        // CALL API AND POST THE IDs
        print_r( $ids );
    }
    add_action( 'xprofile_updated_profile', 'hook_bp_profileupdate', 0, 2 );

    Nothing happens.

    @rchiriac

    Participant

    Can’t EDIT my posts on the forums anymore…
    So my question is: what’s this $posted_field_ids variable? How does it get populated; it’s always NULL, same as $_POST (I’m in edit.php)

    @shanebp

    Moderator

    Remove all the changes listed above that you made to edit.php.

    In functions.php, paste this:

    function something_updated_profile( $user_id, $posted_field_ids, $errors ) {
    	if ( empty( $errors ) ) {
    		print_r( $posted_field_ids ); 
    		echo "<br>user id: " . $user_id . "<br>";
    		print_r( $_POST ); 
    	}
    }
    add_action('xprofile_updated_profile', 'something_updated_profile', 1, 3);

    read this:
    https://codex.wordpress.org/Function_Reference/do_action

    @rchiriac

    Participant

    I read that page before. Still nothing’s echoed.
    I removed all my lines from edit.php there’s just functions.php with your above code, but where does do_action() go now? Still don’t get how $posted_field_ids is populated

    @rchiriac

    Participant

    I re-added this in the edit.php inside the while ( bp_profile_fields() )
    do_action( 'xprofile_updated_profile', bp_displayed_user_id(), bp_get_the_profile_field_id(), trim(strip_tags(bp_get_the_profile_field_value())) );

    Now… Do you know what is the hook do to upon user registration?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Geting input values in Edit Profile page’ is closed to new replies.
Skip to toolbar