Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save greenhornet79/22247a178e8de6816af1fc55cc260bae to your computer and use it in GitHub Desktop.
Save greenhornet79/22247a178e8de6816af1fc55cc260bae to your computer and use it in GitHub Desktop.
<?php
// add the custom field
add_action( 'update_leaky_paywall_subscriber_form', 'testmag_add_company_field' );
function testmag_add_company_field( $user_id ) {
$company = get_user_meta( $user_id, '_company', true );
?>
<p>
<label>Company</label><br>
<input type="text" class="regular-text" value="<?php echo esc_attr( $company ); ?>" name="company">
</p>
<?php
}
// save the custom field when the form is submitted
add_action( 'update_leaky_paywall_subscriber', 'testmag_save_company_field' );
function testmag_save_company_field( $user_id ) {
if ( isset( $_POST['company']) ) {
update_user_meta( $user_id, '_company', sanitize_text_field( $_POST['company'] ) );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment