Hi All,
I have user registration setup with GF & Members. Together with a front-end form. The front end form saves several choices to wp_usermeta - no problem there.
But in the dashboard, I also have form created to allow editing in there as well (for admins).
One of the (new) choices is if the user wants a quarterly newsletter posted or emailed.
I have this as a radio button - with the two choices - emailed or posted.
When choosing in the dashboard, it saves to the DB. But on page load (or reload) it’s not showing the existing choice.
I need help with a php if statement, to add the echo "checked" to the current choice.
Here’s the form I have in my theme functions.php Form Gist
I have a update_user_meta later in the file, so changing the selection reflects in the database.
Nice way to provide engagement options how the user/admins prefer.
You probably want to use the WP core function checked so that something akin to this would work: <input type="radio" id="dnj_post" name="dnj_post" value="emailed" <?php checked( $dnj_value_from_user_meta, 'emailed' ); ?>>
As additional FYI, in case your use case for that form grows in complexity with the need for opt-ins, reminders or adjusting delivery frequency, etc. you could use the Gravity Form Shortcode within a widget and a combination of Gravity Flows Update an Entry Step Type to do similar things without coding the custom form. If it’s not the type of thing where you want to be keeping all the form entries, the Form Connector Delete an Entry step or the GFAPI have options.