I am trying to add a Logic Hook for Emails synced from IMAP Mail server.
In the end i want trigger a hook when a new mail gets synced and check the senders mail if its saved in one of the accounts.
The problem is that the Synced Mails dont get saved (at least not in InboundMail or Emails module) so the after/before_save does not trigger.
Here is my hook from logic_hooks.php:
$hook_array['after_save'][] = Array(1, 'Create Lead', 'custom/modules/InboundEmail/LeadLogicHook.php', 'LeadLogicHook', 'handleLead');
It does not work in InboundEmail and Email Module.
And the LeadLogicHook:
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
class LeadLogicHook
{
function handleLead($bean, $event, $arguments)
{
_ppl("Test");
}
}
Is this even possible with logic hooks?
EDIT: Added some Code
No need for logic hook or any other custom code. Sugar/SuiteCRM use a scheduler job to fetch email from IMAP server. You can check scheduler job function (function::pollMonitoredInboxes) which fetch emails. That contain code which is used for email fetching. track back code and you will find everything you want.
What version of sugar are you using?
You can, for example, generate an after_save hook in the E-mail module instead of inboundEmail
Would be like this:
$hook_array ['after_save'] [] = Array (1,'Create Lead','custom/modules/Emails/LeadLogicHook.php','LeadLogicHook','handleLead');
Do this and see if the email fires!
Another possibility would be to use the after_relationship_add, because usually, the email is associated with some lead, account, or contact. try to create a hook in the module that your email is associating with and generate the operation from there
one last possibility (I do not recommend this) is to create a trigger in your database for when the data enters the table, perform the check and take some action
I think it's possible, if after/before_save not triggering then try some similar logic hooks. The following are some logic hooks that I think could help.
before_retrieve
after_retrieve
before_restore
after_restore
server_roundtrip
after_session_start
after_entry_point
Comment if you want more details, like how to use logic hooks e.t.c.
Related
In WordPress, I have custom registration site for new users. Upon registration, there is an optional checkbox to subscribe to our newsletter. As far as I understand it, it adds the value of the checkbox to the user_meta table (the whole thing has been coded by a company in India, which I woould very much prefer to not involve again, since they delayed their work time and time again and didn't do good work after all).
The corresponding code snippet in my child theme's functions.php looks like this:
<?php echo '<div class="form-row form-row-wide">
<input type="checkbox" name="inter_offers" value="yes"> '; _e('I would like to subscribe to the Kurth Electronic newsletter.','kurth-child'); echo '<br></div>';
return $fields; ?>
add_action('woocommerce_created_customer','adding_extra_reg_fields');
function adding_extra_reg_fields($user_id) {
extract($_POST);
update_user_meta($user_id, 'billing_inter_offers',$inter_offers);
} ?>
(I have left out lines irrelevant to this issue.)
Now, this value is saved internally, but not displayed to me. I would like to show the value in an E-Mail or notification generated by WordPress when the user completes registration, so that we can manually add them to our newsletter list whenever someone chooses to subscribe to the newsletter. The problem is that I only have a limited knowledge of PHP and I don't know where to start.
I should also note that this is not done via the standard WorPress registration form, but by a WooCommerce registration form (I have disabled the standard WordPress registration for security reasons).
I tried using the "Better Notifications" plugin (https://wordpress.org/plugins/bnfw/) for custom notifications whenever a new user completes their registration, but it ignores any php code that I add to the custom notifications body to display the user_meta data.
Any help would be appreciated.
Because the registration is done via woocomerce you may have to look for a notification PlugIN that works with woocomerce, the one you have may just work properly with wordpress core version!
You also could generate a mail via php in the function, so that you get a message with the user mail adress, but i think without php knowledge it is not that easy to use the built in php mailer... (You may need an api there!)
But wouldn't it be better to automatically sign them into your newsletter software? For example for Mailchimp or other systems like that there are quite good wordpress plugins!
You may also be able to include the forms of these PlugIns in your registration form, but without a closer look at this woocomerce registration i can't tell for sure!
I think this will do the trick, it will notify you every time a new user is created and also tell you if they subscribed or not.
function new_customer_registered_send_email_admin($user_login, $user_email) {
ob_start();
do_action('woocommerce_email_header', 'New customer registered');
$email_header = ob_get_clean();
ob_start();
do_action('woocommerce_email_footer');
$email_footer = ob_get_clean();
$user = get_user_by( 'email', $user_email );
$subscribed = get_user_meta( $user->ID, 'billing_inter_offers', true );
woocommerce_mail(
get_bloginfo('admin_email'),
get_bloginfo('name').' - New customer registered',
$email_header.'<p>The user '.esc_html( $user_login ).' created an account ' . ( $subscribed ? ' and subscribed to the newsletter.' : '.' ) . '<br>Email:'.esc_html( $user_email ).'</p>'.$email_footer
);
}
add_action('new_customer_registered', 'new_customer_registered_send_email_admin', 10, 2);
I ended up using the plugin amr users to generate a userlist of all users who had a certain metadata tag set to a certain value (in my case, if they want to recieve a newsletter - the previous developers never bothered to make the data actually readable without extra effort). It is a little clunky to use and not what I originally intended, but it got the job done.
when i add new recepient and sent the document in template using below code
$templateRole = new \DocuSign\eSign\Model\TemplateRole();
$templateRole->setEmail("user#email.com");
$templateRole->setName("User Name");
$templateRole->setRoleName("Admin");
I use Docusign Php Client, you can find the whole code below I used for this on that page.
Here it send the email containing document to user#email.com, but user#email.com's user is not able to sign that document.
I've also added the dynamic text to the document in the template.Added one signer recipient to template (because i was not able to add the dynamic labels without it), this user get all the emails even i don't specify him on the above code.
I want something like to send a document in template to different recepients (like user1#gmail.com, user2#gmail.com etc) one at a time (they may or may not have docusign account, though is it possible if they have docusign account?)
I am doing this since 4 days, not finding anything about proceeding furthur, please help.
I have read some of the documentation. As far as I can see you should do the following:
//first signer
$templateRole1 = new \DocuSign\eSign\Model\TemplateRole();
$templateRole1->setEmail("user1#email.com");
$templateRole1->setName("User1 Name");
$templateRole1->setRoleName("Admin");
//second singer
$templateRole2 = new \DocuSign\eSign\Model\TemplateRole();
$templateRole2->setEmail("user2#email.com");
$templateRole2->setName("User2 Name");
$templateRole2->setRoleName("Admin");
And then in the envelop:
$envelop_definition->setTemplateRoles(array($templateRole1, $templateRole2));
I need to change
logo_url
for transactional emails with external link, for example
https://exampledomainname.com/image.png
but I can't hardcode all or even one file in
app/locale
Is there any way to add external url as logo_url? As when I go here:
System > Configuration > General > Design > Transactional Emails
I can only add image to hosting area
As far as I was looking into the web there is no best practice way to directly rewrite logo_url, but we can create custom variable and then use it into email templates. We can do it manually from admin or using programming way. My requirements is to implement this in programming way, so we start with shell script(shell\external_logo_url.php) to create custom variable:
<?php
require_once '../abstract.php';
class External_Logo_Url extends Mage_Shell_Abstract
{
public function run()
{
$variable = Mage::getModel('core/variable')
->setCode('variable-code')
->setName('variable-name')
->setPlainValue('variable-value')
->save();
}
}
$shell = new External_Logo_Url();
$shell->run();
Also we need to change template files in app\locale, so you need replace all template files or custom templates that you need. You should look for {{var logo_url}} and replace with {{customVar code=variable-code}}.
What i have :
Sugarcrm enterprise 6.5.14
I have set the inbound email to automatically generate cases under some conditions.
(it is set in Sugar's administration > Inbound email, it's native, i didn't write any code, juste setting it up).
I saw on /modules/InboundEmail/InboundEmail.php the function handleCreateCase() which i think (but please, confirm it) is used to generate cases.
What i want :
When a case is generated by an inbound email, the function handleCreateCase() is searching for contact ids and retrieves the good contact with this id :
snippet of handleCreateCases() :
if($contactIds = $this->getRelatedId($contactAddr, 'contacts')) {
if(!empty($contactIds) && $c->load_relationship('contacts')) {
$c->contacts->add($contactIds);
} // if
} // if
Now, i would like to add a "Else" condition : if there is no related contact, then create one.
My question is..
How do i code that? Could i customize the InboundEmail module? Will it be taken by Sugar?
Thanks a lot for your patience and your time.
I am making an application in CodeIgniter and I need a Messaging Library Module there and I got a Library name Mahana. The Link is as follows.
https://github.com/jrmadsen67/Mahana-Messaging-library-for-CodeIgniter/tree/master/application
But I am unable to apply it as it has no controller and View portion. I am very new to CodeIgniter. Can any one provide me any link of total Mahana Librery or any other Messaging Library for CodeIgniter
Thank You
What's your problem ?
First you must create in the db, the tables from the dump mahana.sql,
and after use the variable that are in the configuration file config/mahana.php (USER_TABLE_TABLENAME, USER_TABLE_ID, and USER_TABLE_USERNAME) to integrate with a fast table access.
To use the library just put in your controller :
$this->load->library('mahana_messaging');
after that, when you want to get a message, create an object, and put in the method *get_message* the message id, and sender id, it will return a single message, including the status for specified user.
$mahana = new Mahana_messaging();
$msg = $mahana->get_message($msg_id, $sender_id);
U can also get the full thread of conversation using the method *get_full_thread*, it will return a entire thread conversation. To send a new internal message, that create a new thread, you must use the method *send_new_message* and pass the sender id, the recipient, the subject, the body, and finally the priority (this information, usually will be get from a web form, that you have created previously)
function send_new_message($sender_id, $recipients, $subject='', $body='', $priority=PRIORITY_NORMAL)
and so on ... there are other functions that permit you to reply a message, get partecipant...
Good work
Does this help at all????