• Hello, I have on user profile a field ” business_name ”

    I want to display is this field is filled the business name on profile page instead the default username.

    Thanks

    Michel

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter benenoo

    (@benenoo)

    Hello, I try with this code but doesnt works :

    <?php }
    			
    	
    		if( $profil_statut == "Professionnel"){
    		um_user( 'display_username' );
    	} else {
    		um_user( 'display_name' );
    		
    	} ?>

    @benenoo

    Your code snippet should look like this if I understand your issue right:

    add_action( 'um_after_profile_name_inline', 'um_after_profile_name_inline_custom', 10, 1 );
    
    function um_after_profile_name_inline_custom( $args ) {
    
        if( !empty( um_user( 'profil_status' ) && um_user( 'profil_status' ) == "Professionnel" )) {
    
            $html = ob_get_contents();
            ob_end_clean();
    
            $html = str_replace( um_user( 'display_name' ), um_user( 'business_name' ), $html );
    
            ob_start();
            echo $html;
        }
    }

    Add code snippet to your active theme’s functions.php file
    or use the “Code Snippets” plugin.

    • This reply was modified 2 years, 6 months ago by missveronica.
    • This reply was modified 2 years, 6 months ago by missveronica.
    Thread Starter benenoo

    (@benenoo)

    Thanks very much ??
    works well
    Michel

    Thread Starter benenoo

    (@benenoo)

    One thing again, if I want this code for the free plugin online user, what is the code ?and where add it ?

    Thanks again ??

    Thread Starter benenoo

    (@benenoo)

    I try with this code, but this code display the field from profil_statut and not the display_nane or business_name

    $name = um_user( 'profil_statut' );
    		 if( !empty( um_user( 'profil_statut' ) && um_user( 'profil_statut' ) == "Professionnel" )) {
    			 
    			    $html = ob_get_contents();
            ob_end_clean();
    			$html = str_replace( um_user( 'display_name' ), um_user( 'business_name' ), $html );
    			
    			 ob_start();
            echo $html;
    Thread Starter benenoo

    (@benenoo)

    Thanks for this code

    add_action( 'um_after_profile_name_inline', 'um_after_profile_name_inline_custom', 10, 1 );
    
    function um_after_profile_name_inline_custom( $args ) {
    
        if( !empty( um_user( 'profil_status' ) && um_user( 'profil_status' ) == "Professionnel" )) {
    
            $html = ob_get_contents();
            ob_end_clean();
    
            $html = str_replace( um_user( 'display_name' ), um_user( 'business_name' ), $html );
    
            ob_start();
            echo $html;
        }
    }

    works well, what need to change for the profile search member list and online user

    Thanks very much

    • This reply was modified 2 years, 5 months ago by benenoo.
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘username’ is closed to new replies.