BuddyDev

Search

Buddypress Profile link

  • Participant
    Brovuve on #40327

    Hey, I have created a website https://i3dc178222240.wpcomstaging.com/ but I’m stuck after registration method. I want to user edit their profile after register on website. So how can I do this? I need shortcode of user edit profile so I can add that shortcode in a page and link that page in redirect after registration.

    I’m stuck in this from 2 months can anyone help me?

    Website – https://i3dc178222240.wpcomstaging.com/
    Edit user profile link – https://i3dc178222240.wpcomstaging.com/members/avinav/profile/edit/group/1/
    I want shortcode which open this page.

  • Keymaster
    (BuddyDev Team)
    Posts: 22212
    Brajesh Singh on #40347

    Hi Brovuve,

    Welcome to BuddyDev support forums.

    You can put the following code in your active theme’s(or child theme’s) functions.php

    
    /**
     * Shortcode for generating edit profile link
     */
    add_shortcode( 'bp-edit-profile-link', function ( $atts = array(), $content = '' ) {
    
    	$atts = shortcode_atts( array(
    		'user_id' => get_current_user_id(),
    		'label'   => 'Edit Profile',
    		'class'   => 'edit-profile-link',
    	), $atts );
    
    	if ( empty( $atts['user_id'] ) ) {
    		return '';
    	}
    	$url = get_edit_profile_url( $atts['user_id'] );
    
    	return sprintf( '<a href="%1$s" class="%2$s">%3$s</a>', esc_url( $url ), esc_attr( $atts['class'] ), $atts['label'] );
    
    } );
    

    Now, you can use the shortcode

    
    [bp-edit-profile-link]
    

    You can also pass the edit profile label and css classes using the ‘label’ and ‘class’ attributes.

    If the user is not logged in, It will not sho anything. When the user is logged in, It will show the link to edit profile.

    Hope that helps.

    Regards
    Brajesh

You must be logged in to reply to this topic.

This topic is: not resolved