Instantly share code, notes, and snippets.

Embed
What would you like to do?
Remove State Field from MemberPress Signup Forms
<?php
//Remove the State Field completely
function trim_down_address_fields($options) {
foreach($options->address_fields as $i => $o) {
if($o->field_key == 'mepr-address-state') {
unset($options->address_fields[$i]);
}
}
return $options;
}
add_filter('mepr_fetch_options', 'trim_down_address_fields');
//Add a fake state value to each user
function populate_state_field($event) {
$user = $event->get_data();
update_user_meta($user->ID, 'mepr-address-state', 'fake');
}
add_action('mepr-event-login', 'populate_state_field');
@cartpauj

This comment has been minimized.

Copy link
Owner

cartpauj commented Oct 3, 2018

The above code can be installed in a plugin like Code Snippets or My Custom Functions.

@martin123888

This comment has been minimized.

Copy link

martin123888 commented Nov 23, 2018

Hi Cartpauj,

I was wondering if it is possible to remove any field of your choosing for new sign ups, but have them remain intact for logged in users.
This way people can complete their profile later on.

I have send in a support case with Memberpress regarding this and it may be they respond with a solution as well, but seeing as you seem to be already halfway , I was hoping maybe you could point me in the right direction as well

The reason I would want this, is because I want a higher percentage of people to complete their purchase and according to my CPA/accountant I only need their names , countries and whether they are a business or a consumer... and of course the email for the sign up/purchase.

Now I know there is probably cart software like Woo commerce which can handle this out of the box, but I would rather not add too much junk/plugins for every little function I need ( I may not be much of a programmer but I know that piling up plugins = instability).

Anyway thanks in advance for your time and consideration

Cheers,
Martin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment