• Hi, I’m desperate to email the user when their profile is visited.
    The only code track I found is the following but I can’t manage to adapt it

    function um_custom_email_notifications( $notifications ){
    
    	$notifications['ninja_new_user_logged_in'] = array(
    		'key'           	=> 'ninja_new_user_logged_in',
    		'title'         	=> __( 'Ninja - New user has logged in','um-groups' ),
    		'subject'       	=> '{site_name} - Someone logged-in to your site',
    		'body'          	=> 'Hi,<br /><br />'.
    		                   '"{display_name}" has access to your site right now.<br /><br />'.
    		                   'To view profile, please click the following link: {user_profile_url}',
    		'description'   	=> __('Whether to send the user an email when someone login to the site.','ultimate-member'),
    		'recipient'   	 	=> 'admin',
    		'default_active' 	=> true
    	);
    
    	return $notifications;
    }
    add_filter( 'um_email_notifications', 'um_custom_email_notifications', 10, 1 );
    add_action("wp_login","um_notify_when_someone_logged_in",10, 2);
    function um_notify_when_someone_logged_in( $user_login, $user ){
        $user_id = $user->ID;
        um_fetch_user( $user_id ); 
        $recipient = "[email protected]";
    	$profile_name = um_user("display_name");
    	$profile_url = um_user_profile_url( $user_id );
    
    	UM()->mail()->send( $recipient, 'ninja_new_user_logged_in', array(
    				'plain_text'	 => 1,
    				'tags'				 => array(
    					'{profile_name}',
    					'{profile_url}',
    				),
    				'tags_replace' => array(
    					$profile_name,
    					$profile_url,
    				)
    	) );
    }
Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter stephanefromain

    (@stephanefromain)

    The code is an example of what it is possible to do, I found it on the site of one of the developers of the ultimate member plugin, but I don’t think I have the skill to adapt it

    Plugin Support Aswin Giri

    (@aswingiri)

    Hello @stephanefromain

    Are you trying to email when users log in to their account or when someone else visits their profile?

    Thread Starter stephanefromain

    (@stephanefromain)

    only when someone else visits their profile

    Plugin Support Aswin Giri

    (@aswingiri)

    Hello @stephanefromain

    Please try the following codes, you won’t be able to configure email from the settings area in this but users will receive an email when their profile is visited by logged-in users:

    Find code snippets here.

    Thread Starter stephanefromain

    (@stephanefromain)

    Hello and thank you very much for this feedback!

    I inserted the code but it does not generate an email.
    In addition, the profile only shows the profile picture since and not the full profile?

    Also, I want a non-logged-in user to be able to view the profile and then generate an email to the profile owner.
    If you have a lead, I’m an entrepreneur.
    Many thanks in advance,
    Yours, Stephane

    Plugin Support Ultimate Member Support

    (@ultimatemembersupport)

    Hi @stephanefromain

    I suggest that you add a cookie when visiting the profile so that it triggers the “Visit Profile” notifications once daily. Without this validation, a user can spam the user’s email, and your email providers will mark your mail as spam.

    Thread Starter stephanefromain

    (@stephanefromain)

    Hi, I had another idea. I could generate an email using a form and for that I would have to be able to retrieve the profile email to automatically insert it into the form, but how do I retrieve the profile email? in html or something?

    Exemple profil :

    <div id=”um_field_17856_user_email” class=”um-field um-field-text um-field-user_email um-field-text um-field-type_text” data-key=”user_email”><div class=”um-field-label”><label for=”user_email-17856″>Adresse e-mail</label><div class=”um-clear”></div></div><div class=”um-field-area”><div class=”um-field-value” id=”user_email-17856″>[email protected]</div></div></div>

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Ultimate member email user when profil is visited’ is closed to new replies.