Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

save pos, trigger action and jquery. WordPress

  • SOLVED

On WP post editor, I have inserted a metabox containing a div that composes an image from the features image and the title.
It uses Jquery and ajax, all works fine.

I would like it to create this image automatically when we save the post. I am not a programmer and I don't know how to make a function that could do that - ie trigger the jquery to generate the base64 image and so on.
This is inside a little plugin - if you need it, I can send it to you.

Answers (2)

2020-04-09

Arnav Joy answers:

Hi,
Hope you are doing well and safe!
Can you please show me your code or necessary screenhot so we can understand your requirement more better?
Thanks
Arnav


Gérald Morales comments:

Arnav,

Thank you for answering, I am still alive, thank you :-) Hope you are fine too.

Please get this plugin, install it in a WP test: https://drive.google.com/open?id=1hCtE3NYokNWWi8sWxorMR0Dh2LkwqQB6

Once installed, create a post, with title and featured image. You will see in the editor, bottom of page a metabox: "Campaigndot Banner"

It works fine.
1) We "Generate the banner" to save it in media (works with jquery, Ajax)
2) We "Choose Banner" to save the image inside the post.

But I would like this process automatic when we create the post the first time (not on updates).

I don't know how to make that work…

You can find the code you need in the files :

1 - the metabox : /admin/wes_metabox_posts.php
2 - the function : /admin/wes_metabox_posts.php line 272
3 - the js : /js/send_to_canvas.js


Arnav Joy comments:

Hi,
Which version of wp are you using?
Are you using gutenburg blocks or classic editor?
I installed and activated plugin and I am getting "No user id defined" error and nothing loading for me in admin.


Arnav Joy comments:

Please let me know how I can set up it?

2020-04-09

Hariprasad Vijayan answers:

Hi there,

Could you share a screenshot and code? So we can understand what you are trying to achieve.

Kind Regards,
Hariprasad


Gérald Morales comments:

Hariprasad, thank you for looking - please see my message above.


Gérald Morales comments:

Thank you for answering, I am still alive, thank you :-) Hope you are fine too.

Please get this plugin, install it in a WP test: https://drive.google.com/open?id=1hCtE3NYokNWWi8sWxorMR0Dh2LkwqQB6

Once installed, create a post, with title and featured image. You will see in the editor, bottom of page a metabox: "Campaigndot Banner"

It works fine.
1) We "Generate the banner" to save it in media (works with jquery, Ajax)
2) We "Choose Banner" to save the image inside the post.

But I would like this process automatic when we create the post the first time (not on updates).

I don't know how to make that work…

You can find the code you need in the files :

1 - the metabox : /admin/wes_metabox_posts.php
2 - the function : /admin/wes_metabox_posts.php line 272
3 - the js : /js/send_to_canvas.js


Hariprasad Vijayan comments:

Am getting some errors, and a fatal error. Can't check it from here.


Gérald Morales comments:

Bad. Sorry for that - I don't have errors on my side.


Gérald Morales comments:

Hariprasad, can you eventually send me these errors?


Hariprasad Vijayan comments:

When i publish post i get following erro

Fatal error: Uncaught Error: Call to undefined function strptime() in campaigndot\admin\wes_metabox_posts.php:248

The reason is the function strptime() is not compatible with windows platform.
https://stackoverflow.com/questions/14003227/strptime-function-is-undefined


Gérald Morales comments:

Thank you very much. I'll amend this.