Skip to:
Content
Pages
Categories
Search
Top
Bottom

Simple form to update one xprofile field

  • Avatar of Peterverkooijen
    peterverkooijen
    Participant

    @peterverkooijen

    I want to add one or two fields on an event registration form in a plugin to update the xprofile data of that user. I have no clue where to start with this.

    The query would presumably look something like this:

    $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->bp_xprofile_data} SET value = %s WHERE ID = %d AND field_id=2", $companyname, $user_id ) );

    Lets say I want to create a form from scratch to update one field ‘companyname’ in xprofile. If there’s already data in that field it should echo that on the form as value.

    How do I echo the value? What do I need to get the data from the form to the query? How do I make sure the update is made in the records of the logged-in user?

    Is there an example anywhere of a basic xprofile update form? Built-in examples in BP all use arrays and loops, they’re not for specific single fields in xprofile. It’s very hard to figure out what’s going on if you’re not a php programmer.

You must be logged in to reply to this topic.