Hello,
Advanced Custom Fields is more useful using it together with your other plugin Live-Edit.
Live-Edit eases the front-end editing and makes the custom fields editing possible. However, I ever have queries or a support request, I could n’t get reply at the support section at official WordPress repository. May I know if you deal support requests elsewhere?
Thanks!
Hi @sjeev
I don’t often reply to support on the live edit plugin, as this was a small plugin from some time ago.
Feel free to ask your question here.
Thanks
E
function init()
{
// must be logged in
if( is_user_logged_in() && current_user_can('author') || current_user_can('administrator'))
{
// actions
add_action('admin_head', array($this,'admin_head'));
add_action('admin_menu', array($this,'admin_menu'));
add_action('wp_enqueue_scripts', array($this,'wp_enqueue_scripts'));
add_action('wp_head', array($this,'wp_head'));
add_action('wp_footer', array($this,'wp_footer'));
add_action('wp_ajax_live_edit_update_width', array($this, 'ajax_update_width'));
}
}
I tried this code intending to allow authors and admins to edit. But again, the authors have access to all the posts which are not their own.
So better if you could help me making the plugin work as per the WordPress’s native post access capability. I can also do myself if you guide me through.
Hi @sjeev
The logic above makes sense, so it shouls prevent any of the functionality from running if the user is can not ‘author’.
Perhaps you need to do some debugging in your code. Perhaps your if statement is not working as intended. You should simplify it and print out some results to make sure the current_user_can function is working correctly.
Thanks
E
Hi @sjeev
There is a good topic regarding the current_user_can function here:
http://stackoverflow.com/questions/13404284/wordpress-capabilities-and-current-user-can-in-functions-php
Lets go back to the live edit init function and simplify the code to:
<?php
/*
* init
*
* @description:
* @created: 7/09/12
*/
function init()
{
// must be logged in
if( is_user_logged_in() )
{
if( current_user_can('author') )
{
echo '<pre>';
print_r('author');
echo '</pre>';
die;
}
if( current_user_can('ministrator') )
{
echo '<pre>';
print_r('ministrator');
echo '</pre>';
die;
}
// actions
add_action('admin_head', array($this,'admin_head'));
add_action('admin_menu', array($this,'admin_menu'));
add_action('wp_enqueue_scripts', array($this,'wp_enqueue_scripts'));
add_action('wp_head', array($this,'wp_head'));
add_action('wp_footer', array($this,'wp_footer'));
add_action('wp_ajax_live_edit_update_width', array($this, 'ajax_update_width'));
}
}
?>
This will now visually display some text so you can see if the if statement is working correctly.
I’m guessing the plugin is abandoned? Would be great if it worked with repeaters and layouts. Oh well :/
@UnionDesign, not sure if you’re still using ACF, but at least with the current version of ACF5 PRO, I have working Repeater Fields in Live-Edit. I am using some custom code to grab all the fields in a group however, so if vanilla isn’t working out for you (or anyone else who may find this) then you can check out the gist at https://gist.github.com/Daronspence/4ec625d1e371543dfa93
Hope this helps!
@daron, how would I implement this in my template?
Here’s my template code:
// check if the repeater field has rows of data
if( have_rows('sections') ):
while ( have_rows('sections') ) : the_row();
//OPEN SECTION
echo '<section id="' . get_sub_field('section_id') . '">';
//OPEN CONTAINER
echo '<div class="container">';
if( have_rows('rows') ):
while ( have_rows('rows') ) : the_row();
//OPEN ROW
echo '<div class="row" id="' . get_sub_field("row_id") . '">';
if( have_rows('columns') ):
// loop through the rows of data
while ( have_rows('columns') ) : the_row();
//OPEN COLUMN
echo '<div ';
if(function_exists("live_edit")){
live_edit('column_content');
};
echo ' class="'. get_sub_field("column_classes") .'" id="'. get_sub_field("column_id") .'">';
echo get_sub_field("column_content");
// Close Column
echo '</div>';
endwhile;
endif;
// Close Row
endwhile;
echo '</div>';
//CLose Container
endif;
echo '</div>';
echo '</section>';
endwhile;
endif;
The above template has nested repeater fields.
I can create sections, which contains rows,which contains columns, with content.
The topic ‘ACF makes a good combo with Live-Edit’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.