Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

Viewing 15 replies - 1 through 15 (of 15 total)

  • MorgunovVit
    Participant

    @morgunovvit

    Hi!
    Just put it in a functions.php file of your child-theme.


    MorgunovVit
    Participant

    @morgunovvit

    Hi!
    I’ve solved it! If somebody interesting of it, there’s the solutions here: https://buddypress.org/support/topic/how-to-set-display_name-xprofile-custom_field-at-the-user-registration/


    MorgunovVit
    Participant

    @morgunovvit

    So, it seems that I’ve done it!
    Thanks shanebp for the tip.

    Here’s the code of function for changing display-name:

    add_action( 'bp_core_activated_user', 'change_user_defaults', 99, 3 ); 
    function change_user_defaults($user_id, $key, $user) {
    
        if (empty($user_id)) {
            $user_id = bp_loggedin_user_id();
        }
    
        if (empty($user_id)) {
            return false;
        }
    
        $mv_first_name = xprofile_get_field_data(26, $user_id);
        $mv_last_name = xprofile_get_field_data(11, $user_id); 
        $name = $mv_first_name . ' ' . $mv_last_name; 
        
        
        if ($name !== ' ') {
            $args = array(
                'ID' => $user_id,
                'display_name' => $name
            );       
            wp_update_user($args);
        }
    }

    MorgunovVit
    Participant

    @morgunovvit

    Hi, shanebp!
    Thank you for answering the question!

    Could you explain a point: “Instead of a register hook, try using an activation hook”?
    Where I am to use do_action( ‘bp_core_activated_user’, $user_id, $key, $user ); ?

    And why do you think, that I register hook?


    MorgunovVit
    Participant

    @morgunovvit

    Hi, Josh!
    I am trying to solve a similar problem, but only I need to make the display_name = First_Name + Last_Name fields of the BuddyPress xprofile.

    I have been tormenting for a long time and can’t find a suitable hook that firing when the xprofile fields First_Name and Last_Name have already been written in the database.


    MorgunovVit
    Participant

    @morgunovvit

    It’s still actual question.


    MorgunovVit
    Participant

    @morgunovvit

    Prashant, big thanks!
    But will it be fixed in new upgrade? Do you know?


    MorgunovVit
    Participant

    @morgunovvit

    I’ve tried to use these code:

    function mv_send_additional_emails($user_id){
    $user = get_userdata($user_id);
    $mv_options = get_option('mv_email_admin_option');
    $mv_message = $mv_options? $mv_options['textarea'] : null;
    $cc_mail = $mv_options ? $mv_options['input'] : null;		
    $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
    		
    $message = sprintf(__('New user registred on site %s:'), $blogname) . "<br>\r\n\r\n";
    $message .= sprintf(__('User login: %s'), $user->user_login) . "<br>\r\n\r\n";
    $message .= sprintf(__('E-mail: %s'), $user->user_email) . "\r\n\r\n";
    $message .= sprintf(__('Message text: %s'), $mv_message) . "<br>\r\n\r\n";
    
    /* BuddyPress xprofile */
    $mv_xp_bp_phone =xprofile_get_field_data( 23, $user_id ); // Phone field idd = 23
    $mv_last_name =xprofile_get_field_data( 24, $user_id ); // Last_name field id =24
    
    $message .= sprintf(__('Phone: %s; Last name: %s;' ), $mv_xp_bp_phone, $mv_last_name) . "\r\n";		
    	$headers = array(
    	'From: Sitename <noreply@mc21academy.ru>',
    	'content-type: text/html',
    	'Cc: '
    	);
    // send e-mail to admin
    @wp_mail(get_option('admin_email'), sprintf(__('[%s] New user registered'), $blogname), $message, $headers);}
    	
    add_action('user_register', 'mv_send_additional_emails'); 

    But it didn’t work – the xprofile filds return empty (null).
    But if i try to get xprofile field data for existing user – it works fine
    for example for user id = 1 – xprofile_get_field_data( 23, 1 )) returns: ‘+7 911 810 35 05’!

    I also tried to use another hook: add_filter(‘bp_core_signup_send_validation_email_message’, ‘mv_send_additional_emails’, 10, 3)
    But it doesn’t work too


    MorgunovVit
    Participant

    @morgunovvit

    Hi, Prashant!
    Could you describe in more detail why you advise using wp_new_user_notification_email for admin notification?
    And could You give some example?


    MorgunovVit
    Participant

    @morgunovvit

    The same question and the same problem!


    MorgunovVit
    Participant

    @morgunovvit

    Hi, Prashant Singh!
    Thanks a lot for the advice!

    It seems that I can not wait for help in finding and eliminating the cause of the error, so this solution remains the best.


    MorgunovVit
    Participant

    @morgunovvit

    I’ve counted title chars manually and with Word and with Notepad++ after Error appeared (too big title). And it was less than 80 chars with whitespaces and punctuations.


    MorgunovVit
    Participant

    @morgunovvit

    Yes, sure, but I talk about this forum.


    MorgunovVit
    Participant

    @morgunovvit

    Hi, Varun!
    Thanks for your attention and for your answer.
    I’ve tryed to play with all kind of settings – that was useless because nav block was absent. Only changing BuddyPress template helped.


    MorgunovVit
    Participant

    @morgunovvit

    I have the same problem!
    I think it’s a konflict with anoter plugins.

Viewing 15 replies - 1 through 15 (of 15 total)
Skip to toolbar