Hello, I thought I’d share my final code for others to use if desired. Basically this code awards a BadgeOS badge on approval and send an e-mail to buffer with the links details.
Because I want to encourage users to submit links, I use this code to publish tweets that include their twitter user name. a ‘twitter’ usermeta is used so it needs to be added there. If it’s not there, the url & its title will be published without the name of the submitter.
I hope this helps!
function educadme_links_to_buffer( $linkdata, $linkextradata ) {
$buffer_email = "[email protected]";
// General Link Info
$get_link_title = $linkdata['link_name'];
$get_link = $linkdata['link_url'];
// Dynamic Conditions of Submitter
// User Login of the submitter
$submitter = $linkextradata['link_submitter'];
// Get User Object
$user = get_user_by( 'login', $submitter );
// Get User ID
$user_id = $user->ID;
// Award a badge to the user for Link Approval
if (function_exists('badgeos_maybe_award_achievement_to_user')) {
badgeos_maybe_award_achievement_to_user( '63057', $user_id );
}
// Gets User Meta Twitter for Submitter
$submitter_user_twitter = get_user_meta($user_id, 'twitter', true);
if (isset($submitter_user_twitter)){
$social_title =New Link: $get_link_title by @$submitter_user_twitter";
} else {
$social_title =New Link: $get_link_title";
}
// Output Buffer Commands
$buffer_commands = "
@p YourBufferChannel \r\n
@link $get_link
";
wp_mail( $buffer_email, $social_title, $buffer_commands );
}
add_action( 'link_library_approval_email', 'educadme_links_to_buffer', 10, 2 );