RedFruits: PHP API for wordpress development
any body can show how to use (5 posts)

  1. pescadito01
    Posted 5 years ago #

    ok, may be it's possible to show a form in a post but next how to pass the data to the post content, categories or custom fields structure?

    where the input data are saved?

    can anybody show any example to use?


  2. Inigo Gonzalez
    Posted 5 years ago #

    Ok, pescadito01. Do you want to make a plugin with this funcionality?

    It's possible making a shortcode. For example, the shortcode will show the form and It must save the data where you want.

    In few minutes I can show you a little example.

  3. Inigo Gonzalez
    Posted 5 years ago #

    Here is the solution. Steps:

    1. Create a folder called Pescadito in the plugins folder.
    2. Create a PHP file called Pescadito.php. This is the code:

    Plugin Name: Pescadito

    Plugin URI: http://pescadito.com

    Description: pescadito example!!

    Author: RedFruits team

    Version: 1.0

    Author URI: http://redfruits.wordpress.com

    if (!defined('REDFRUITS_PATH')) define('REDFRUITS_PATH', dirname(dirname(__FILE__)).'/redfruits/');
    if (!defined('PESCADITO_PATH')) define('PESCADITO_PATH', dirname(__FILE__).'/');
    if (!defined('ADMIN_RENDER')) define('ADMIN_RENDER', 'ADWordpressRender');
    if (!defined('resources_db_adapter')) define('resources_db_adapter', 'wordpress');


    class Pescadito extends ADWPPlugin
    function __construct()
    $this->addShortCode('pescadito', PESCADITO_PATH.'shortcodes/PescaditoSC.class.php', 'PescaditoSC');
    new Pescadito();
    3. A new folder (inside Pescadito folder) called shortcodes.
    4. a new file (inside shortcodes) called PescaditoSC.class.php. This is the code:
    class PescaditoSC extends ADLayer
    function render()
    if (is_single()) //only shows when the post is being displayed, not in the category list
    $form = $this->add(new ADForm('pescadito_form'));
    $form->add(new ADLabeledField('First name:', new ADTextField('first_name', '', 20, 40)));
    $form->add(new ADLabeledField('Last name:', new ADTextField('last_name', '', 20, 40)));
    $form->add(new ADSubmit('pescadito_save', 'save'));
    $form->addRequirement('first_name', 'required', 'the first name field must be completed');
    if (isset($_REQUEST['pescadito_save']))
    if ($form->runRequirements($_REQUEST))
    //TODO save the data
    global $post;
    echo 'TODO: Save data \'', $_REQUEST['first_name'], '\' and \'', $_REQUEST['last_name'], '\' in post id ',$post->ID, '';
    return parent::render(ADMIN_RENDER);

    And that's all!!!!

    I'll try to make a post in http://redfruits.wordpress.com with this example and with more comments.

    See you

  4. Inigo Gonzalez
    Posted 5 years ago #

    Remember to write [pescadito] in the post that you want to show the request form!!

  5. pescadito01
    Posted 5 years ago #

    thanks inigoini, just give some days to try it

    best regards, pescadito

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic