Support » Plugin: New User Approve » Custom Email Tags and Messages

  • Hi,

    I would like to make a custom email tag in the email-tags.php file that is in the includes folder of the plugin.

    I want to make one that will output the Facebook URL that is in a user’s WordPress profile from a custom field in the registration form when they registered.

    Is this possible? And also, how would I go about it without editing the plugin’s files directly?

    Also, how to I create a custom email message without editing the plugin’s files directly?

Viewing 1 replies (of 1 total)
  • Hi sandrakgosana
    Yes you can do that. recently i have totally changed this plugin using action/filters. so follow this instruction.

    // add this function in your active child theme. make sure you need to change your facebook url as per your requirement

    function add_email_tag($email_tags) {
        
        $email_tags[] = array(
        'tag'         => 'facebook_url',
        'description' => __( 'Some URL to add to the New User Approve emails' ),
        'function'    => 'facebook_email_tag_url',
        'context'     => array( 'email' ),
        );
        return $email_tags;
    }
    add_filter( 'nua_email_tags', 'add_email_tag', 5);

    // get facebook url based on user id

    function facebook_email_tag_url( $attributes ) {
     global $wpdb;
     $username = $attributes['user_login'];
      $user = $attributes['user'];
      $fblink= get_the_author_meta('facebook_url', $user->ID);
     return $fblink;
    }

    // modify approve email using action/filters

    function custom_approved_email() {
    	$message = __( 'Thank you for your particpiate at {sitename}', 'new-user-approve' ) . "\r\n\r\n";
    	$message .= __( 'You have been approved to access {sitename}', 'new-user-approve' ) . "\r\n\r\n";
    	$message .= "{username}\r\n\r\n";
    	$message .= "{facebook_url}\r\n\r\n";
        $message .= __( 'To set or reset your password, visit the following address:', 'new-user-approve' ) . "\r\n\r\n";
        $message .= "{reset_password_url}";
    	
    	return $message;
    }
    add_filter( 'new_user_approve_approve_user_message_default', 'custom_approved_email',5);

    //here you can change default message, same way you can change other messages as per action/filter

    /* default message for login page */

    function custom_welcome_message() {
    	$welcome = sprintf( __( 'Your custom message here.', 'new-user-approve' ), get_option( 'blogname' ) );
    	return $welcome;
    }
    add_filter( 'new_user_approve_welcome_message_default', 'custom_welcome_message',5);

    so this is solution as per your question. Please add proper facebook url as per your input name in form.

    Thanks
    Ahir Hemant

    • This reply was modified 8 months, 3 weeks ago by  Ahir Hemant.
    • This reply was modified 8 months, 3 weeks ago by  Ahir Hemant.
Viewing 1 replies (of 1 total)
  • The topic ‘Custom Email Tags and Messages’ is closed to new replies.