I am trying to create a frontend edit profile form that mimics the wp-admin backend edit profile. I created the form as HTML directly in a WordPress page (I'm a PHP/WordPress beginner, so I don't know how to write plugins), using shortcode plugins (see technical notes) to correctly populate the form.

I've discovered that the backend edit profile automatically generates a nonce that is placed as a hidden input in the form (id/name = '_wpnonce'). Because my form doesn't generate the nonce, submitting my form results in "Are you sure you want to do this? Please try again". How can I generate the nonce in my form?

I've tried using PHP in the Page (see technical notes) to generate the nonce. An example attempt was [php]echo wp_nonce_field('update-user_' . $user_id)[/php], but it returns nothing. Is there a way to generate the nonce in my Page without building a plugin to create my form?

Technical notes:

  • Using the plugin "Register plus Redux" to create custom user fields. The plugin adds the fields to the backend edit profile.
  • Using plugins "User meta shortcodes" and "Get User Custom Field Values" to populate the form with the users current profile settings.
  • Using plugin "Allow PHP in Posts and Pages" to include PHP directly in Pages (through a [php][/php] shortcode)
  • 1
    You should really implement the form as a separate plugin. Get rid of all those dependencies, use only code you understand thoroughly. – fuxia Feb 15 '14 at 19:41
  • I'm not really at the point of creating my own plugin. I've only been working with PHP and WordPress for about a week. Because the site is pretty small scale, I'm trying to keep my time investment to an appropriate level. – Nate Carrier Feb 15 '14 at 20:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.