BuddyDev

Search

to the connection of an existing member: change (role, plan)

  • Participant
    Level: Enlightened
    Posts: 126
    Hervé on #14418

    Hello,
    I have a big problem right now with a conflict between the theme and the management plugin members. The paid support (especially armember) is not very nice.
    I have to find a solution.
    The goal is to change the role and plan of members to login only for a member with all required fields filled, a photo, having a role and a filled xprofile field.

    I use for that what I understood of the program that you had made:
    https://buddydev.com/support/forums/topic/automatic-change-of-type-with-member-types-pro/page/2/
    https://gist.github.com/sbrajesh/238153f70f770f957fd1c4b2ba60be77
    The info is well stored in user_meta? I did not find that with the interesting plugin:
    https://fr.wordpress.org/plugins/jsm-show-user-meta/

    The particularity is that one is at the time of the connection without I can use the conventional role test (according to developer on a forum).
    So I try this code but it does not work. thank you for helping me

    add_action('wp_login', 'prov_transfert', '99', 2); 
    function prov_transfert($user_login, $user) { 
    	$user_id = $user->ID;
    	$num_plan_abonne='1';
    	$num_plan_payant_1an='4'; 
    	$field_jesuis = '57'; 
    	$jesuis = xprofile_get_field_data($field_jesuis,$bp->loggedin_user->id ); //  $user_id );
    	
    	$has_fields_complete = get_user_meta( $user_id, '_has_required_field_data', true );
    	$has_photo = $this->has_uploaded_avatar( $user_id );
    
    	if ( $has_photo && $has_fields && $user->has_cap('subscriber') && ($jesuis='Une Femme')) {
    				$this->mark_complete_profile( $user_id );
    				$incomplete = false;
    				do_action( 'buddydev_bp_user_profile_completed', $user_id );
    				do_action('arm_apply_plan_to_member', $num_plan_payant_1an, $user_id); // change plan
    				$user_id->add_role( 'membre0' ); // change role
    	}
    }

    Regards

  • Participant
    Level: Enlightened
    Posts: 126
    Hervé on #14558

    Hello
    Help me please
    Regards

  • Keymaster
    (BuddyDev Team)
    Posts: 24190
    Brajesh Singh on #14569

    I am sorry but I am unable to be of much help with 3rd party plugins(specially if they are not BuddyPres, WooCommerce or the very popular ones).

    If it is about changing roles, I can help but I will need you to rephrase the question and specify the goals.

    Thank you
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 126
    Hervé on #14575

    Hello Brajesh

    Ok forget the only line (do_action(‘arm_apply_plan_to_member’, $num_plan_payant_1an, $user_id);) on the armember component (which works in your other code). I have to do a program to solve a role loss problem

    The idea is at the moment of connection (That’s when I can not do it, I think), check if the member has
    * a photo
    * all mandatory fields filled
    * a subscriber role
    * a special value for an xprofile field

    If yes I change the role of the member (member0)

    Regards

  • Participant
    Level: Enlightened
    Posts: 126
    Hervé on #14825

    Hello Brajesh
    A little reminder if you could help me
    Have a good day
    Regards

  • Participant
    Level: Enlightened
    Posts: 126
    Hervé on #14883

    Hello Brajesh
    Sorry! I forgot to say that it is more urgent because there are members who remain in the subscriber state (a little complicated to explain but I think it is due to the change of programming with an existing site).
    This program would allow me to solve this too
    Regards

  • Participant
    Level: Enlightened
    Posts: 126
    Hervé on #15020

    Hello Brajesh
    This poses a real problem for the members!
    Is it difficult or can not you do it?

    Regards

    • This reply was modified 5 years, 11 months ago by Hervé.
  • Keymaster
    (BuddyDev Team)
    Posts: 24190
    Brajesh Singh on #15029

    Hi Herve,

    I am sorry but I am not able to assist on it.
    The problem is not that I can not do it, the problem is use of the 3rd party membership plugin. I don’t have any domain knowledge of that plugin and I am unable to spend time on that specific plugin.

    Without the domain knowledge, I am handicapped and that’s why I haven’t been able to assist you with it.

    The best person to help you on this are the membership plugin developer. I can help in the BuddyPress section or anything they need.

    Thank you
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 126
    Hervé on #15065

    Hello Brajesh
    So all is well If I talked about the other plugin, it was to explain why I developed this program. We can forget it.
    My problem is related to the connection sequence with wordpress buddypress. To be clearer, the only important code that does not work is

    
    
    add_action('wp_login', 'prov_transfert', '99', 2); 
    function prov_transfert($user_login, $user) { 
    	$user_id = $user->ID;
    	$num_plan_abonne='1';
    	$num_plan_payant_1an='4'; 
    	$field_jesuis = '57'; 
    	$jesuis = xprofile_get_field_data($field_jesuis,$bp->loggedin_user->id ); //  $user_id );
    	
    	$has_fields_complete = get_user_meta( $user_id, '_has_required_field_data', true );
    	$has_photo = $this->has_uploaded_avatar( $user_id );
    
    	if ( $has_photo && $has_fields && $user->has_cap('subscriber') && ($jesuis='Une Femme')) {
    				$this->mark_complete_profile( $user_id );
    				$incomplete = false;
    				do_action( 'buddydev_bp_user_profile_completed', $user_id );
    				
    				$user_id->add_role( 'membre0' ); // change role
    	}
    }
    
    

    The idea is at the moment of connection (That’s when I can not do it, I think), check if the member has
    * a photo
    * all mandatory fields filled
    * a subscriber role
    * a special value for an xprofile field

    If yes I change the role of the member (member0)
    Is this good?
    Regards

    • This reply was modified 5 years, 11 months ago by Hervé.
    • This reply was modified 5 years, 11 months ago by Hervé.
  • Participant
    Level: Enlightened
    Posts: 126
    Hervé on #15231

    Hello,
    I removed the part related to another plugin.It remains the part with your other program. Is it clearer now?
    Can you help me ?
    Regards

You must be logged in to reply to this topic.

This topic is: not resolved