Skip to:
Content
Pages
Categories
Search
Top
Bottom

Redirecting to profile page after submitting a valid edit profile form

  • @rebootnow

    Participant

    I would like to return the user to the profile page after they have submitted valid changes in the edit form. Of course, if the input isn’t valid, I would like to stay on the form and display error messages (i.e. the way it works now).

    I have spent some time looking at “xprofile_edit()” in bp-xprofile.php, and it looks like this function would have to be reworked significantly.

    Has anyone done something like this?

Viewing 1 replies (of 1 total)
  • @rebootnow

    Participant

    Like many things, this wasn’t as hard as I initially thought it would be. I replaced “xprofile_edit()” with my own version “_xprofile_edit()” that I put in functions.php.

    I removed all html output from the new function and put it in a variable instead. This way I could call my “_xprofile_edit()” before the header in /profile/edit.php (in the member theme) and use “wp_redirect( $bp->loggedin_user->domain )” to send the user back to the profile page if their input was valid.

    My new function returns the html markup for the form, which is rendered where the theme previously called “bp_edit_profile_form()”.

    My one slight concern is that I had to change the call to “wp_nonce_field()” in the function. I can’t allow it to echo anything, since this code is run before the header, so I set the last parameter of “wp_nonce_field()” to $echo = false. I understand the nonce in principle, but I’m not quite sure what this echo was achieving in the first place, so there is a chance that I have removed something that was important for security.

    Any thoughts on that would be appreciated.

Viewing 1 replies (of 1 total)
  • The topic ‘Redirecting to profile page after submitting a valid edit profile form’ is closed to new replies.
Skip to toolbar