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! :slight_smile:

    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 :slight_smile: )

    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! :slight_smile:


Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.