I use google-api-php-client-v3 to connect my application to Google Calendar and create/delete events. When I try to create recurring events, it seems that the Recurrence rule is not recognized by Google.
$event = new Google_Service_Calendar_Event();
$event->setSummary($session->summary);
$event->setLocation($session->location);
$start_date = new Zend_Date($session->date_debut . ' ' . $session->start_date);
$end_date = new Zend_Date($session->date_fin . ' ' . $session->end_date);
$start = new Google_Service_Calendar_EventDateTime();
$start->setDateTime($start_date->get(Zend_Date::RFC_3339));
$start->setTimeZone('America/Montreal');
$event->setStart($start);
$end = new Google_Service_Calendar_EventDatetime();
$end->setDateTime($end_date->get(Zend_Date::RFC_3339));
$end->setTimeZone('America/Montreal');
$event->setEnd($end);
$event->setRecurrence(array('RRULE:FREQ=DAILY;COUNT=6;INTERVAL=1;'));
In the event properties, the Repeat property indicates:
This recurrence rule can not Be edited in Google Calendar.
Click Cancel to keep current rule .
Edit rule and click Done to override current rule .
In an event created directly in Calendar if I apply the same Recurrence rule, it is recognized!
Repeat: Daily 6 times
What I'm missing?
Thanks for any help!
This behavior seems to be caused by the trailing semicolon. Using the string 'RRULE:FREQ=DAILY;COUNT=6;INTERVAL=1' allows the recurrence to be editable in the Google Calendar UI.
Related
Guys I'm writting a wordpress site to run a knowldge base for our Service desk. As one person will be updating it i needed to have a field for who wrote the kb artical. I'm tring to add a custom field into my wordpress theme to display writtenby using Advance custom Fields. Now I'm using echo Knowledge Base plugin for knowldge base.
I've got as far add ing code below will display the text below the last up date value that plugin creates. However i cannot get it to put value from the custom field on the page after this. The plugin creates the page using php below the ive added the two lines as below.
$wb = get_post_meta($post->ID, 'Writtenby', true);
echo ' Last Update Writtenby:'.$wb.' ';
// LAST UPDATED ON
public static function last_updated_on( $args ) {
echo '' . esc_html( $args['config']['last_udpated_on_text'] ) . ' ' . EPKB_Utilities::get_formatted_datetime_string( $args['article']->post_modified, 'F d, Y' ).'';
$wb = get_post_meta($post->ID, 'Writtenby', true);
echo ' Last Update Written by:'.$wb.' ';
}
Advanced Custom Fields plugin use a little bit different system to store postmeta. Try to use get_field() instead get_post_meta()
If you have the ID
$customField = get_post_meta($my_id, "_mcf_customField", true);
However if you want to get the ID from the object:
$customField = get_post_meta($post_id->ID, "_mcf_customField", true);
After much more work looks like at the point the page was being created it had no reference to partical page not even a current one. They where writting to an array all artical numbers and info.
So by telling get_field which artical to get the writtenby field from it now displayed data and not blank
$wb= get_field('Writtenby', $args['article']->ID);
I am using this https://docs.woocommerce.com/document/create-a-coupon-programatically/ code to generate coupon code programmatically.
It's work good. But every time that generate UNIQUECODE same name code. I want to generate different code every time.
Example : UNIQUECODE12, UNIQUECODE14, UNIQUECODE16 etc.
So please help me how this possible.
Thanks.
You could create a WordPress option using the Options API that is a coupon counter. You can access and increment the counter every time you use it.
<?php
add_option( 'coupon-count', 0 ); // only sets it if it isn't in the database
$coupon_count = get_option( 'coupon-count' ); // access count
$coupon_count++; // increment the count
update_option( 'coupon-count', $coupon_count ); // store the incremented count for
$coupon_code = 'UNIQUECODE' . '-' . $coupon_count; // Numbered Code
I want to modify the expires_at of my client , when i do persist($client) and flush(); every method works fine except setExpiresAt() it doesn't change the value in table.
$client = $em->getRepository('ClientBundle:Client')->FindClient($id);
$expiresat = $client->getExpiresAt(); // the can see the (*)
$expiresat->modify($durationcontract);
$client->setExpiresAt($expiresat);
// $durationcontract can be 6 months or one year
$client->setDuration($durationcontract);
$em->persist($client);
$em->flush();
(*) this method doesn't exist in Class User or the FOSUserBundle its created by me. you can see it here
Maybe Doctrine doesn't see the difference between objects.
So, try this:
$expiresat = $client->getExpiresAt();
$expiresat = clone $expiresat;
$expiresat->modify($durationcontract);
$client->setExpiresAt($expiresat);
I am trying to customize wordpress for my needs and I manged to do allot of changes but I can't figure out this one by my self.
I don't want to allow to authors to set up time stamp for the past, I do want this option to be enabled but only for posting new posts in the feature. So the minimum required date is today so if they pick a date before today they will get a message or something and the post won't progress.
Does anyone have any Idea how can I accomplish this with plugin or maybe a filter ?
Thanks to everyone who helps :)
http://codex.wordpress.org/Plugin_API/Action_Reference/save_post is what you need.
add_action('save_post', 'stop_publishing', 20);
function stop_publishing($post_id)
{
$post = get_post($post_id);
$post_date = $post->post_date;
$current_date = date("Y-m-d");
//do your math of date calculation
//user has set a date in the past, I am using an imaginary variable date_is_not_valid
if ( $date_is_not_valid ) {
$message = '<p>Please enter current or future date.</p>'
. '<p>Edit post</p>';
wp_die($message, 'Error - Incorrect Date!');
}
}
In my symfony2 application I need to display some totals at the top of all pages, ie "Already 200,154,555 users registered".
I don't want to run the query to come up with that count on every page load. The solution I've come up with is to create a "variable" entity that would have two columns, name and value. Then I would set up a console command that runs on cron which would update these variable entities (eg "totalPeople") with a query that counted all the rows of people, etc.
This feels a little heavy handed... Is there a better solution to this problem?
You could set global parameters and add a service to rewrite them. Then call the service from your Command.
Or directly set up a service to read/write a file (as a json array for example).
Or set up a option table with a row storing the data. It's not going to be a resource intensive query that way.
Here is what I'm using to store RSS feeds (after I parsed them)
public function checkCache($data=array(), $path = '')
{
foreach ($data as $service => $feed)
{
$service = strtolower($service);
$service = str_replace(' ', '-', $service);
$path = $path.'web/bundles/citation/cache/rss/' . $service . '.cache';
if ((!file_exists($path) || time() - filemtime($path) > 900) && $cache = fopen($path, 'w'))
{
$rss_contents = $this->getFeed($feed); //fetch feed content & returns array
fwrite($cache, serialize($rss_contents));
fclose($cache);
return $rss_contents;
}
else
{
$cache = fopen($path, 'r');
return unserialize(file_get_contents($path));
fclose($cache);
}
}
}
You can implement that on your backend for example so every time an admin logs it'll check for cache and refresh only if it's too old. Although I'm quite fond of the 4AM cron job solution too.
You could use the pagination feature of doctrine (if you use doctrine). That will leverage the "limit" part of your queries (even with joins) and will give you a total count of rows (via a count query).