-
Author
-
August 10, 2014 at 17:46 #25286alberhdParticipant
I have this fail,when i add the code in sweetdate-child/functions.php
Fatal error: Cannot redeclare kleo_pmpro_default_level() (previously declared in /homepages/43/d524894821/htdocs/wp-content/themes/sweetdate-child/functions.php:87) in /homepages/43/d524894821/htdocs/wp-content/themes/sweetdate-child/functions.php on line 116
August 12, 2014 at 22:20 #25510CatalinModeratorthat error appears because probably you already declared it in the functions.php file from your child theme…
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionAugust 12, 2014 at 22:27 #25512alberhdParticipantDo you say that probably is because the code is already entered on /sweetdate-child/functions.php?
Is the first time that i enter this code,but i will check,thank you for your help.
Im talking about this code: https://archived.seventhqueen.com/forums/topic/membership-auto-in-registration
August 12, 2014 at 22:35 #25513alberhdParticipantAh ok,maybe i know the problem,i enter both codes,confusion! and is just one of them, right?
COPY CODEadd_action('user_register', 'kleo_pmpro_default_level'); function kleo_pmpro_default_level($user_id) { pmpro_changeMembershipLevel(1,$user_id); }
OR
COPY CODE/** * When registering, add the member to a specific membership level * based on the field value he has selected * * @global object $wpdb * @global object $bp * @param integer $user_id */ function kleo_pmpro_default_level($user_id) { global $wpdb, $bp; //Change this with your field name $field_name= "I am a"; //Change the field value $value_to_match = "Woman"; //Membership level id $membership_level = 1; //Done editing $field_id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->profile->table_name_fields} WHERE name = %s", $field_name ) ); if ($_POST['field_'.$field_id] == $value_to_match) { pmpro_changeMembershipLevel($membership_level, $user_id); } } function kleo_mu_pmpro_default_level($user_id, $password, $meta) { global $bp, $wpdb; //Change this with your field name $field_name= "I am a"; //Change the field value $value_to_match = "Woman"; //Membership level id $membership_level = 1; //Done editing $field_id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->profile->table_name_fields} WHERE name = %s", $field_name ) ); $field_value = $meta['field_'.$field_id]; if ( $field_value == $value_to_match ) { pmpro_changeMembershipLevel($membership_level, $user_id); } } if (is_multisite()) { add_action( 'wpmu_activate_user', 'kleo_mu_pmpro_default_level', 10, 3); } else { add_action('user_register', 'kleo_pmpro_default_level'); }
If I understand good the first code,if I create a membership free,that on the list of the plugin is the membership number 1,when the user will enter on the page,automatically they will have this membership right?
August 13, 2014 at 14:37 #25570CatalinModeratorplease tell me what you want to achieve in your site.
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution -
AuthorPosts
The topic ‘Assign default Membership level at registration (Problem)’ is closed to new replies.