Support

Account

Home Forums Search Search Results for 'q'

Search Results for 'q'

reply

  • Ah, I see – this is mitigated by the use of quotes:

    array(
    	'key' => 'course_tutors',
    	'value' => '"' . get_the_ID() . '"',
    	...
    )
    
  • Hi all, won’t a LIKE query searching for post ID ‘1’ return a row with i.e. ’12’ (a post of ID 12), which would be an error?

    If so, how can we avoid this error?

  • Champion! That fixed the issue! Thanks! Sorry for all the replies – we got there eventually! If there are any further issues I will post entire code blocks next time!

    One quick question, is your advancedcustomfields.com/my-account/ a custom built area? Is it woocommerce with a custom theme?

    Thanks again.

  • Hi

    after u create front end form pls put following function in your function.php, add the required filed to post

    add_filter(‘acf/pre_save_post’ , ‘my_pre_save_post’ );
    function my_pre_save_post( $post_id ) {
    // check if this is to be a new post
    if( $post_id != ‘new’ ) {
    return $post_id;
    }

    $field = $_POST[‘fields’];
    $post_title = $_POST[‘fullname’];
    $post_content = $field[‘edit_test2’];
    $post = array(
    ‘post_status’ => ‘draft’ ,
    ‘post_title’ => $post_title,
    ‘post_content’ => $post_content,
    ‘post_type’ => ‘page’

    );
    $newpost_id=wp_insert_post($post);
    if($newpost_id!=0)
    {

    $fullname=$_POST[‘fullname’];
    $address=$_POST[‘address’];
    add_post_meta($newpost_id,’FullName’, $fullname);
    add_post_meta($newpost_id, ‘address’, $address);
    }
    }

    You can also refer following article
    http://www.advancedcustomfields.com/resources/tutorials/using-acf_form-to-create-a-new-post/

  • Hi here is solutions create html form

    <form method=”post” action=”#” class=”acf-form form-horizontal ” id=”post” enctype=”multipart/form-data”>
    <?php
    $args = array(
    ‘post_id’ => ‘new’,
    ‘field_groups’ => array(1), //use wrong ID of your custom field Form so form fields will not get shown
    ‘form’ => false
    );
    acf_form($args);
    ?>
    //file upload button
    <div data-field_type=”file” data-field_key=”field_5343d9b2586f0file” data-field_name=”email” class=”field field_type-text field_key-field_5343d9b2586f0file” id=”acf-file”>
    <p class=”label”><label for=”acf-field-file”>Image</label></p>
    <div class=”acf-input-wrap”>
    <input type=”file” id=”my_image_upload” name=”my_image_upload”>
    </div>
    <input id=”submit_my_image_upload” name=”submit_my_image_upload” type=”submit” value=”Submit” />

    // in function .php write following code
    //Here we gather the files which sent by the HTML forms. and send it to //another function called kv_handle_attachement(). This is a simple function //this will help you to store the files to your wp uploads directory. Add //the following code into your Theme “ functions.php”
    //img upload//
    function kv_handle_attachment($file_handler,$post_id,$set_thu=false) {
    // check to make sure its a successful upload
    if ($_FILES[$file_handler][‘error’] !== UPLOAD_ERR_OK) __return_false();

    require_once(ABSPATH . “wp-admin” . ‘/includes/image.php’);
    require_once(ABSPATH . “wp-admin” . ‘/includes/file.php’);
    require_once(ABSPATH . “wp-admin” . ‘/includes/media.php’);

    $attach_id = media_handle_upload( $file_handler, $post_id );

    // If you want to set a featured image from your uploads.
    if ($set_thu) set_post_thumbnail($post_id, $attach_id);
    return $attach_id;
    }
    //New File Upload

    add_filter(‘acf/pre_save_post’ , ‘my_pre_save_post’ );
    function my_pre_save_post( $post_id ) {
    // check if this is to be a new post
    if( $post_id != ‘new’ ) {
    return $post_id;
    }

    $field = $_POST[‘fields’];
    $post_title = $_POST[‘fullname’];
    $post_content = $field[‘edit_test2’];

    // Create a new post
    require_once(ABSPATH . “wp-admin” . ‘/includes/image.php’);
    require_once(ABSPATH . “wp-admin” . ‘/includes/file.php’);
    require_once(ABSPATH . “wp-admin” . ‘/includes/media.php’);
    $attachment_id = media_handle_upload( ‘my_image_upload’, $post_id );
    $post = array(
    ‘post_status’ => ‘draft’ ,
    ‘post_title’ => $post_title,
    ‘post_content’ => $post_content,
    ‘post_type’ => ‘page’

    );
    $newpost_id=wp_insert_post($post);
    if($newpost_id!=0)
    {

    add_post_meta($newpost_id, ‘picture’, $attachment_id );

    }
    }`

    Let me know if u have any question , its works perfectly fine

    Thanks

  • hi

    have you tried some code pls share I will suggest you change it seems all of your requirements are related PHP coding

    If your requirements are limited to following only

    How not to show the library files when uploading the front end?
    1) create html form to upload image
    http://www.kvcodes.com/2013/12/create-front-end-multiple-file-upload-wordpress/

    2) How to define the format of files that can attached?
    Refer following code here u can limit type file to be uploaded
    3) How to limit the amount of files that can be attached?
    by following code u can limit the size of file

    <?php
    $allowedExts = array(“gif”, “jpeg”, “jpg”, “png”);
    $temp = explode(“.”, $_FILES[“file”][“name”]);
    $extension = end($temp);

    if ((($_FILES["file"]["type"] == "image/gif")
    || ($_FILES["file"]["type"] == "image/jpeg")
    || ($_FILES["file"]["type"] == "image/jpg")
    || ($_FILES["file"]["type"] == "image/pjpeg")
    || ($_FILES["file"]["type"] == "image/x-png")
    || ($_FILES["file"]["type"] == "image/png"))
    && ($_FILES["file"]["size"] < 20000)
    && in_array($extension, $allowedExts)) {
    if ($_FILES["file"]["error"] > 0) {
    echo "Error: " . $_FILES["file"]["error"] . "<br>";
    } else {
    echo "Upload: " . $_FILES["file"]["name"] . "<br>";
    echo "Type: " . $_FILES["file"]["type"] . "<br>";
    echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
    echo "Stored in: " . $_FILES["file"]["tmp_name"];
    }
    } else {
    echo "Invalid file";
    }
    ?>

  • This reply has been marked as private.
  • Thanks that answered my question. Funnily enough I have already created a custom taxonomy for my email templates so I should be sorted there. Cheers for the advice 🙂

  • I have a client I just created a site for with a products CPT that has a related products field. They have nearly 800 products and all of them are listed… in a “more” sorta way. When you scroll to the bottom of the current list the next few are loaded. The search works perfectly and loads pretty quickly.

    I would suggest that you also create a custom taxonomy for your email templates that allows the email templates to be sorted into “categories”. I’d probably name the taxonomy ’email-template-types’ 🙂 In the future, when there are 1000’s or templates this may help the users find them faster.

  • Just check the wordpress update process. After installing a new version of wordpress, the process goes through every database of the network (5 websites each step) and does the required updates.

    The multisite function of wordpress is absolutely powerful.

  • @theatereleven

    I’ll be creating the pages and accounts for this particular project, so it’s simpler than what you’re doing. But another project requires user-driven account creation and we’re using Gravity forms as well…so we’ll look into your solution.

    I also thought that BuddyPress would do all of this…surprising that it doesn’t.

    Good to know about Tabby Tabs…looks useful.

    Thanks again!
    Seth

  • I had to write a converter script to update some fields and this is how I set up the Google map field $value array. Worked fine.

    
    $field_name = "field_53bdd058c84a8";
    $value = array("address" => $address, "lat" => $lat, "lng" => $lng, "zoom" => $zoom);
    update_field($field_name, $value, $this_ID);
    
  • This reply has been marked as private.
  • Hi @robbie

    Thanks for the info. I’m interested to use your above field group code to test the issue myself, but can’t copy / paste the code due to all quotes being converted to html characters.

    Are you able to edit your comment and re-post your code within backticks to prevent the html entity issue?

    Cheers
    E

  • Hi @raabe

    Thanks for the feature request. I haven’t worked with multi-site much before, so do you have any advice or other plugins which already do this?

    Perhaps ACF can follow the standard approach that others are doing.

  • hi

    many user facing this problem and no proper solution for this, but here is work around for this issue , We will not use acf_form rather than that we need to create a html form

    create html form

    `<form method=”post” action=”#” class=”acf-form form-horizontal ” id=”post” enctype=”multipart/form-data”>
    <?php
    $args = array(
    ‘post_id’ => ‘new’,
    ‘field_groups’ => array(1), //use wrong ID of your custom field Form so form fields will not get shown
    ‘form’ => false
    );
    acf_form($args);
    ?>
    //file upload button
    <div data-field_type=”file” data-field_key=”field_5343d9b2586f0file” data-field_name=”email” class=”field field_type-text field_key-field_5343d9b2586f0file” id=”acf-file”>
    <p class=”label”><label for=”acf-field-file”>Image</label></p>
    <div class=”acf-input-wrap”>
    <input type=”file” id=”my_image_upload” name=”my_image_upload”>
    </div>
    <input id=”submit_my_image_upload” name=”submit_my_image_upload” type=”submit” value=”Submit” />

    // in function .php write following code
    //Here we gather the files which sent by the HTML forms. and send it to //another function called kv_handle_attachement(). This is a simple function //this will help you to store the files to your wp uploads directory. Add //the following code into your Theme “ functions.php”
    //img upload//
    function kv_handle_attachment($file_handler,$post_id,$set_thu=false) {
    // check to make sure its a successful upload
    if ($_FILES[$file_handler][‘error’] !== UPLOAD_ERR_OK) __return_false();

    require_once(ABSPATH . “wp-admin” . ‘/includes/image.php’);
    require_once(ABSPATH . “wp-admin” . ‘/includes/file.php’);
    require_once(ABSPATH . “wp-admin” . ‘/includes/media.php’);

    $attach_id = media_handle_upload( $file_handler, $post_id );

    // If you want to set a featured image from your uploads.
    if ($set_thu) set_post_thumbnail($post_id, $attach_id);
    return $attach_id;
    }
    //New File Upload

    add_filter(‘acf/pre_save_post’ , ‘my_pre_save_post’ );
    function my_pre_save_post( $post_id ) {
    // check if this is to be a new post
    if( $post_id != ‘new’ ) {
    return $post_id;
    }

    $field = $_POST[‘fields’];
    $post_title = $_POST[‘fullname’];
    $post_content = $field[‘edit_test2’];

    // Create a new post
    require_once(ABSPATH . “wp-admin” . ‘/includes/image.php’);
    require_once(ABSPATH . “wp-admin” . ‘/includes/file.php’);
    require_once(ABSPATH . “wp-admin” . ‘/includes/media.php’);
    $attachment_id = media_handle_upload( ‘my_image_upload’, $post_id );
    $post = array(
    ‘post_status’ => ‘draft’ ,
    ‘post_title’ => $post_title,
    ‘post_content’ => $post_content,
    ‘post_type’ => ‘page’

    );
    $newpost_id=wp_insert_post($post);
    if($newpost_id!=0)
    {

    add_post_meta($newpost_id, ‘picture’, $attachment_id );

    }
    }`

    Let me know if u have any question , its works perfectly fine

    Thanks

  • Okay, I finally figured this out on my own. I studied the get_field_object() function more deeply, and on this documentation page, in the “field_key vs field_name” section, there is a hint. It is not said directly, but apparently even if posts have been created that use the Field Group, if a filter causes the current query of posts (using the pre_get_posts hook) to return none of them, field_name won’t work. Even Elliot used the field_name in his tutorial, but in the case of a filter like this, you MUST use the field_key, even though it makes the code harder to read.

  • Hi @thomask

    Thanks for the info.
    The translation has been added to allow other translation plugins such as polylang to work.

    I don’t want to remove the functionality as this will break some sites, but agree that a solution is required for both situations to work correctly.

  • By the way, with ACF 5 this “bug” has been corrected. ACF now allows you to save the post with the “yes/no” in either state, even if set to “required”. Which means that the “required” option on “yes/no” fields is completely meaningless now.

  • deepfriedfilth, I have no idea how that would have been a solution to the problem.

    However, with the release of ACF 5 and its new layout this feature request has, obviously, become obsolete.

  • Thank you for that idea. I don’t know how or whether to implement it. Here is my code:

    add_action('genesis_before_sidebar_widget_area', 'sidebar_custom_field');
    function sidebar_custom_field() {
    if ( is_single() && genesis_get_custom_field('sidebar_custom_field') )
    echo '<div class="widget">'. genesis_get_custom_field('sidebar_custom_field') .'</div>';
    }
  • I edited the code in my question above.

    I changed:

    elseif( is_category() )

    to:

    elseif( is_category() || is_single() )

    And so now it works for both pages and posts within a certain category, but not the categories themselves (the index/archive/category pages).

  • Hm, it looks like neither of the joins are sending along the post_type, which I imagine is probably part of the problem…

    action:acf/fields/relationship/query
    field_key:field_535ad94b471e0
    nonce:9f1a98d75f
    post_id:7332
    max:
    s:
    post_type:
    taxonomy:
    action:acf/fields/relationship/query
    field_key:field_53c982bbe7eab
    nonce:9f1a98d75f
    post_id:7332
    max:
    s:
    post_type:
    taxonomy:

    And neither is getting any response back.

  • o wait, thsi seems to work:

    function fields_in_feed($content) {  
        if(is_feed()) {  
            $post_id = get_the_ID();  
            $output .= '<p>' . get_post_meta($post_id, "text", true) . '</p>';    
            $content = $content.$output;  
        }  
        return $content;  
    }  
    add_filter('the_content','fields_in_feed');
  • Ignore the first question – I gave up completely on allowing multiple selections, as it ran into too many problems and the case where we might need more than one is purely theoretical, so I decided to keep it simple for now.

    But the second issue needs solving if I’m going to have these filters at all. As I said, the problem can easily be seen on the tutorial video at timecode 11:05, so it’s not something unique to my code. If anyone else has implemented such a filter, how did you deal with get_field_object() failing when the result set is empty? This looks like a bug in get_field_object() to me.

Viewing 25 results - 18,051 through 18,075 (of 21,330 total)