Skip to Content Skip to Menu

Automatically create and article, owned by newly created user ?

  • rbuelund
  • rbuelund
  • OFFLINE
  • Posts: 565
  • Thanks: 40
  • Karma: 4
10 months 5 days ago - 9 months 3 weeks ago #335890 by rbuelund
Is it possible to use auto actions to automatically create an article onAfterUserCreation, which belongs to a certain given category and has this new user as it's author/owner ?
Last edit: 9 months 3 weeks ago by rbuelund.

Please Log in or Create an account to join the conversation.

  • rbuelund
  • rbuelund
  • OFFLINE
  • Posts: 565
  • Thanks: 40
  • Karma: 4
10 months 5 days ago #335891 by rbuelund
Sorry - I can answer this myself! Auto actions - Content - simply perfect :-) But - does this also support cusom fields for the created article ?

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48325
  • Thanks: 8254
  • Karma: 1443
10 months 5 days ago #335896 by krileon

But - does this also support cusom fields for the created article ?

No, it's a very simple implementation for generating articles. If you need something more complex it's probably best to use a Code action with Method set to PHP and utilize Joomla API to generate the article.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • rbuelund
  • rbuelund
  • OFFLINE
  • Posts: 565
  • Thanks: 40
  • Karma: 4
10 months 5 days ago #335898 by rbuelund
Hmm.. I just tried this code just for test creation of an article. I just been led to the frontpage when triggering the auto action and no article is created and no error message - any ideas ?
Code:
$newapp = Factory::getApplication(); $mvcFactory = $newapp->bootComponent('com_content')->getMVCFactory(); $articleModel = $mvcFactory->createModel('Article', 'Administrator', ['ignore_request' => true]); $article = [     'catid' => 8,     'alias' => 'tttttttttttttttt44',     'title' => '123My Article Title 44',     'introtext' => 'My Article Intro Text',     'fulltext' => 'My Article Full Text',     'created_by' = '618',     'state' => 1,     'attribs' = '{"article_layout":"","show_title":"","link_titles":"","show_tags":"","show_intro":"","info_block_position":"","info_block_show_title":"","show_category":"","link_category":"","show_parent_category":"","link_parent_category":"","show_associations":"","show_author":"","link_author":"","show_create_date":"","show_modify_date":"","show_publish_date":"","show_item_navigation":"","show_icons":"","show_print_icon":"","show_email_icon":"","show_vote":"","show_hits":"","show_noauth":"","urls_position":"","alternative_readmore":"","article_page_title":"","show_publishing_options":"","show_article_options":"","show_urls_images_backend":"","show_urls_images_frontend":""}',    'metadata' = '{"robots":"","author":"","rights":"","xreference":""}',     'language' => '*', ]; if (!$articleModel->save($article)){     throw new Exception($articleModel->getError()); }

Please Log in or Create an account to join the conversation.

  • rbuelund
  • rbuelund
  • OFFLINE
  • Posts: 565
  • Thanks: 40
  • Karma: 4
10 months 4 days ago #335901 by rbuelund
I know the former question about the code may not be directyly CB related, but I wonder how I can see if there are any errors raised when I run it with auto action ?

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48325
  • Thanks: 8254
  • Karma: 1443
10 months 4 days ago #335906 by krileon
Enable debug mode under Parameters to see error output. It's likely failing because you're trying to use Factory class without specifying its namespace path.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum