How can I add %FirstName% to Automessage

I have the first names of my users and which to use Dear %FirstName% in the messages.

What do I need to add to the class.user.php file to get this to work please?

  • Michael Bissett

    Hey Paul, hope you're having a good day today!

    It's possible to achieve this, but it will require you to modify the plugin, will will mean that you'll want to note the changes made, as they'll be lost on an update to the plugin.

    (please make backups of the files to be edited, just to be safe )

    Replace the code presently between lines 46-58 of automessage/classes/class.user.php with the following code:

    if(function_exists('get_blog_option')) {
    					$replacements = array(	"/%blogname%/" 	=> 	get_blog_option( $blog_id,'blogname'),
    								"/%blogurl%/"	=>	untrailingslashit(get_blog_option( $blog_id,'home')),
    								"/%username%/"	=>	$this->user_login,
    								"/%usernicename%/"	=>	$this->user_nicename,
    								"/%userfirstname%/"	=>	$this->user_firstname
    							);
    				} else {
    					$replacements = array(	"/%blogname%/" 	=> 	get_option('blogname'),
    								"/%blogurl%/"	=>	untrailingslashit(get_option('home')),
    								"/%username%/"	=>	$this->user_login,
    								"/%usernicename%/"	=>	$this->user_nicename,
    								"/%userfirstname%/"	=>	$this->user_firstname
    							);
    				}

    As for showing that constant inside the edit page for an automessage, you'll need to add the following code to lines 990 & 1089 of automessage/classes/class.automessage.php:

    echo "%userfirstname%<br/>";

    Let me know if this helps please!

    Regards,
    Michael