Viewing 1 replies (of 1 total)
  • Plugin Author eventualo

    (@eventualo)

    Hi, in registration form there is the checkbox to allow new users to subscribe or not the newsletter.
    Anyway, you can force the subscription with a code like this:

    
    function custom_subscribe_on_save_registration ( $user_id, $password="", $meta=array() )  {
    	$user = get_userdata( $user_id );
    	if (!empty($user->first_name) && !empty($user->last_name)) {
    		$name = $user->first_name.' '.$user->last_name;
    	} else {
    		$name = $user->display_name;
    	}
    
    	$fields['email'] = $user->user_email;
    	$fields['name'] = $name;
    
    	if ( function_exists ('alo_em_add_subscriber') )
    	{
    		alo_em_add_subscriber( $fields, 1, alo_em_get_language(true) );
    	}
    }
    add_action( 'user_register', 'custom_subscribe_on_save_registration' );
    

    I hope it helps.

    • This reply was modified 5 years, 3 months ago by eventualo.
Viewing 1 replies (of 1 total)
  • The topic ‘Auto subscribe on registration’ is closed to new replies.