Created
September 22, 2022 20:56
-
-
Save greenhornet79/22247a178e8de6816af1fc55cc260bae to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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