BuddyDev

Search

[Resolved] BP Autologin on Activation

  • Participant
    Level: Enlightened
    Posts: 47
    blade on #2884

    Dear @Brajesh,

    Im using your old but very awesome plugin:
    BP Autologin on Activation

    1) Still works perfectly! Thank you very much!

    2) I tried adding your code from the comment to redirect to /profile/edit (functions.php):
    <div id=”highlighter_62467″ class=”syntaxhighlighter php”>
    add_fllter(‘bpdev_autoactivate_redirect_url’,’redirect_to_edit_profile’);
    function redirect_to_edit_profile($user_id){
    return bp_core_get_user_domain($user_id ).”profile/edit/”;
    }</div>
    But $user_id seems to empty at this time.
    I also tried following code:
    <div id=”highlighter_62467″ class=”syntaxhighlighter php”>
    add_fllter(‘bpdev_autoactivate_redirect_url’,’redirect_to_edit_profile’);
    function redirect_to_edit_profile($user_id){
    return get_option( ‘home’ ) . ‘/members/’ . bp_core_get_username( $user_id ) . ‘/profile/edit/’;
    }</div>
    same results.

    3) My goal: redirect on activation dependant on the member-type.
    I wrote the following script for a redirect plugin, which i would like to replace with yours:
    <div id=”highlighter_62467″ class=”syntaxhighlighter php”>
    $member_type = bp_get_member_type($user->ID);
    if( $member_type == ‘Student’ || $member_type == ‘student’ ) {
    $redirect_url = ‘/wordpress/members/’.$user->user_login.’/profile/edit/group/6/#edit-personal-li’;
    }
    else if( $member_type == ‘Teacher’ || $member_type == ‘techer’ ) {
    $redirect_url = ‘/wordpress/members/’.$user->user_login.’/profile/edit/group/5/#edit-personal-li’;
    }
    else {
    $redirect_url = ‘/wordpress/members/’.$user->user_login.’/profile/’;
    }</div>

    Perhaps this snippet could be useful to someone 🙂

    Gratefully
    Blade

  • Participant
    Level: Enlightened
    Posts: 47
    blade on #2885

    oh, cant edit OP. Doublepost for format – sorry all:

    Dear Brajesh,

    Im using your old but very awesome plugin:
    BP Autologin on Activation

    1) Still works perfectly! Thank you very much!

    2) I tried adding your code from the comment to redirect to /profile/edit (functions.php):

    
    
    add_fllter(‘bpdev_autoactivate_redirect_url’,’redirect_to_edit_profile’);
    function redirect_to_edit_profile($user_id){
    return bp_core_get_user_domain($user_id ).”profile/edit/”;
    }
    

    But $user_id seems to empty at this time.
    I also tried following code:

    
    
    add_fllter(‘bpdev_autoactivate_redirect_url’,’redirect_to_edit_profile’);
    function redirect_to_edit_profile($user_id){
    return get_option( ‘home’ ) . ‘/members/’ . bp_core_get_username( $user_id ) . ‘/profile/edit/’;
    }
    

    same results.

    3) My goal: redirect on activation dependant on the member-type.
    I wrote the following script for a redirect plugin, which i would like to replace with yours:

    
    $member_type = bp_get_member_type($user->ID);
    if( $member_type == ‘Student’ || $member_type == ‘student’ ) {
    $redirect_url = ‘/wordpress/members/’.$user->user_login.’/profile/edit/group/6/#edit-personal-li’;
    }
    else if( $member_type == ‘Teacher’ || $member_type == ‘techer’ ) {
    $redirect_url = ‘/wordpress/members/’.$user->user_login.’/profile/edit/group/5/#edit-personal-li’;
    }
    else {
    $redirect_url = ‘/wordpress/members/’.$user->user_login.’/profile/’;
    }

    Perhaps this snippet could be useful to someone 🙂

    Gratefully
    Blade

  • Keymaster
    (BuddyDev Team)
    Posts: 22510
    Brajesh Singh on #2898

    Hi Blade,
    My apologies for the delayed reply.
    Please use this code instead.

    
    add_filter( 'bpdev_autoactivate_redirect_url','redirect_to_edit_profile', 10, 2 );
    
    function redirect_to_edit_profile( $profile_url, $user_id  ) {
    	return $profile_url .'profile/edit/';
    }
    
    

    It will work. Please let me know if that works for you or not?

    Thank you
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 47
    blade on #2899

    Hey my master!
    I just solved it via trial&error like a stupid xD

    
    add_filter('bpdev_autoactivate_redirect_url','redirect_to_edit_profile');
    function redirect_to_edit_profile($user_id){
             return $user_id.'profile/edit/';
    }
    

    I found out (at least think i did) that $user_id at this specific hook time is already the full url,
    thats why bp_core_get_user_domain($user_id) can’t find the “user_id”, thus returning the url without the name.
    I dont know if it makes any sense, but that was my noob-logic (and i’m a very beginner in wordpress)

    Never the less I will test your solution asap, and report back to you.

    Million thanks for being like you are Brajesh!!!
    Gratefully

    Blade

  • Participant
    Level: Enlightened
    Posts: 47
    blade on #2900

    Test report:

    IT IS WORKING!

    Topic marked as resolved 🙂

  • Participant
    Level: Enlightened
    Posts: 47
    blade on #2901

    Afterwords:

    Using my code might be less characters, but i’m using your code, because having the proper $user_id is much better for modifications.
    Here are my modifications to your solution to also differentiate between member-types and redirecting to the “detailed” edit profile page. (not the general)
    Perhaps someone find this useful:

    
    
    function redirect_to_edit_profile( $profile_url, $user_id  ) {
    	if( bp_get_member_type($user_id) == 'your-member-type-1' ) {
    	return $profile_url .'profile/edit/group/2/';
    	}
    	else if( bp_get_member_type($user_id) == 'your-member-type-2' ) {
    	return $profile_url .'profile/edit/group/5/';	
    	}
    }
    
    

    You have to change:
    – “your-member-type-1” & “your-member-type-2” to match your membertype-names
    – group-number to redirect to [varies with the amount of field-groups you created per member-type]

    Cheers
    Blade

    • This reply was modified 6 years, 11 months ago by blade.
  • Keymaster
    (BuddyDev Team)
    Posts: 22510
    Brajesh Singh on #2903

    Hi Blade,
    Thank you.

    I am sure it will help others. Thank you for sharing 🙂

  • Participant
    Level: Enlightened
    Posts: 47
    blade on #2904

    You give us so much l0ve and I just wanted to give some back 🙂

    Do you know how to trigger this redirect at click on “edit profile”?

    I found a perfect solution ( of course from you, from whom else ):

    
    <?php global $bp;
    
    if(bp_get_current_profile_group_id()==1)
    
    bp_core_redirect($bp->displayed_user->domain."profile/edit/group/2");
    
    ?>
    

    Sadly its 5 years old, and implementing this gives me following error:

    Warning: Cannot modify header information – headers already sent by (output started at C:\xampp\htdocs\wordpress\wp-includes\class.wp-styles.php:172 in C:\xampp\htdocs\wordpress\wp-includes\pluggable.php on line 1228

    I checked everything, there is no newline or space 🙁
    Somehow I cant call a redirect at that time.

  • Keymaster
    (BuddyDev Team)
    Posts: 22510
    Brajesh Singh on #2910

    Hi Blade,
    Please give it a try

    
    add_action( 'bp_actions', 'bp_custom_redirect_to_2ndgroup' );
    
    function bp_custom_redirect_to_2ndgroup() {
    
    	if ( bp_is_user_profile_edit() && bp_get_current_profile_group_id() == 1 ) {
    		bp_core_redirect(bp_displayed_user_domain() . 'profile/edit/group/2' );
    	}
    
    }
    
    

    Please do let me know if that works for you or not?

    Thank you
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 47
    blade on #2913

    Hi Brajesh!

    Everything your hand touches, is working a 100% 😀
    Thank you soo much my master!!!

    Blade

The topic ‘ [Resolved] BP Autologin on Activation’ is closed to new replies.

This topic is: resolved