Shape the future of Social networking with WordPress: Join Project Midnight Sun! The next generation platform for community building with WordPress!

BuddyDev

Search

Replies

  • Keymaster
    (BuddyDev Team)
    Posts: 25494
    Brajesh Singh on in reply to: bp_core_signup_user set a role #27025

    Hi Jennifer,
    Thank you for sharing the code.

    I have updated it slightly and it should work.

    
    
    add_action( 'quform_post_process_7', function ( array $result, Quform_Form $form ) {
    	if ( ! function_exists( 'bp_core_signup_user' ) ) {
    		return;
    	}
    	$username = $form->getValueText( 'quform_7_6' );
    	$email    = $form->getValueText( 'quform_7_6' );
    	$password = $form->getValueText( 'quform_7_7' );
    
    	// XProfile fields
    	$usermeta = array(
    		'field_1'  => $form->getValueText( 'quform_7_10' ),
    		//correo
    		'field_43' => $form->getValueText( 'quform_7_6' ),
    	);
    
    	$usermeta['profile_field_ids'] = '1,43';
    	$usermeta['password']          = wp_hash_password( $password );
    
    	$user_id = bp_core_signup_user( $username, $password, $email, $usermeta );
    	if ( $user_id ) {
    		update_user_meta( $user_id, '_is_shop_manager', 1 );
    	}
    
    	return $result;
    }, 10, 2 );
    
    function after_bp_activated_user( $user_id, $key, $user ) {
    	$user = get_userdata( $user_id );
    
    	$role = 'shop_manager';// please changew ith correct role.
    
    	$is_shopmanager = get_user_meta( $user_id, '_is_shop_manager', true );
    	if ( $is_shopmanager ) {
    		$user->set_role( $role );
    	}
    }
    
    add_action( 'bp_core_activated_user', 'after_bp_activated_user', 30, 2 );
    
    

    Please make sure to use correct role in the 2nd function. Also, It will only work on non multisite installation as on multisite ‘bp_core_signup_user’ does not return the user id correctly(currently).

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25494
    Brajesh Singh on in reply to: [Resolved] BuddyPress Course Stats Widget #27024

    Hi,
    You are most probably using a LMS and that is causing it. Please look into your plugins list and see if there is anything related to LMS, try disabling it temporarily to try the customize again.

    If that resolves it, Please report to the plugin author.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25494
    Brajesh Singh on in reply to: [Resolved] Hide in BuddyPress Activity ShortCode #27022

    You are welcome.

  • Keymaster
    (BuddyDev Team)
    Posts: 25494
    Brajesh Singh on in reply to: [Resolved] Hide in BuddyPress Activity ShortCode #27016

    Thank you.

    The problem is your theme uses dynamic context for the activity actions.

    here is a solution(Though it may be problematic in future)

    
    
    .bpas-shortcode-activities .activity-inner+div {
      display:none;
    
    }
    
    

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25494

    Thank you for confirming. I am glad it worked 🙂

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25494
    Brajesh Singh on in reply to: [Resolved] Hide in BuddyPress Activity ShortCode #27012

    Hi Philippe,
    That should have worked.

    if it did not, can you please link me to the site where I can see it(with a guest user account).
    It should be a simple task.

    regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25494
    Brajesh Singh on in reply to: bp_core_signup_user set a role #27009

    Hi Jennifer,
    The bp_core_signup_user returns the user_id of the newly created user. You can store a meta and use that at the time of activation to check.

    Hope that helps.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25494

    You are welcome.

    you may want to try something like this instead

    
    
    add_filter( 'bp_force_profile_completion_skip_check', function ( $skip ) {
    
    	$user_roles = wp_get_current_user()->roles;
    	if ( in_array( 'donor', $user_roles, true ) ) {
    		$skip = true;
    	}
    
    	return $skip;
    } );
    

    We need to get the role of current user. So, I have updated the code.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25494
    Brajesh Singh on in reply to: bp_core_signup_user set a role #27006

    Hi Jennifer,
    thank you for the question.

    BuddyPress overrides the roles on user account activation.

    Your best bet is to set role on ‘bp_core_activated_user’ action with priority 2 or lower.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25494

    Thank you for the kind words.
    I am glad it is resolved. No issues with reporting here.

    Also, thank you for the youtube link 🙂

    Best regards
    Brajesh