andp
Forum Replies Created
-
Forum: Plugins
In reply to: [Autoptimize] Problem with Facebook OG imageHello i disabled “inline all CSS” and the problem seems to be fixed. is there a way to enable “inline all CSS” without causing this problem?
Forum: Plugins
In reply to: [CMB2] Repeatable GroupsRepeatable Groups are great but i m facing some difficulties. using cmb2 i managed to create the desired custom meta fields for my user and my custom post type.
using
echo get_post_meta(get_the_ID(), ‘submitted_note’, true);
i am able to display the value of my custom field on the front-end.i am straggling though to do this with me repeatable group values.
in my db i have something like this
a:1:{i:0;a:6:{s:25:”submitted_hotel_name”;s:14:”hotel one”;s:28:”submitted_hotel_acronym”;s:6:”depone”;s:28:”submitted_hotel_address”;s:4:”fdsd”;s:29:”submitted_hotel_postcode”;s:5:”sdfsd”;s:25:”submitted_hotel_city”;s:6:”sdfsdf”;s:28:”submitted_hotel_country”;s:6:”sdfsdf”;}}can u give me a quick hint of how to display a single value i.e submitted_hotel_postcode only.
thank u
Forum: Plugins
In reply to: [CMB2] Repeatable Groupsseems ok after changing the css. thank you michael
Forum: Plugins
In reply to: [CMB2] Repeatable GroupsForum: Plugins
In reply to: [CMB2] Repeatable Groupshello firebug doesnt give me any erros
Forum: Plugins
In reply to: [CMB2] Repeatable Groupshello again
i am trying to work with repeating groups on the frontend but can make it.
i am using your simple examples. first of all i installed cmb2 plugin from wordpress. then i added these lines in my themes functions. The group works fine on the back end. On the frontend everything works ok except the toggle icon. Any suggestions?
you can have a look here (https://www.sight79.net/demosite/sample-page/)
/**
* Get the bootstrap!
*/
if ( file_exists( __DIR__ . ‘/cmb2/init.php’ ) ) {
require_once __DIR__ . ‘/cmb2/init.php’;
} elseif ( file_exists( __DIR__ . ‘/CMB2/init.php’ ) ) {
require_once __DIR__ . ‘/CMB2/init.php’;
}//CREATE METABOX
add_action( ‘cmb2_init’, ‘cmb2_sample_metaboxes’ );
function cmb2_sample_metaboxes() {
// Start with an underscore to hide fields from custom fields list
$prefix = ‘_yourprefix_’;
$cmb_group = new_cmb2_box( array(
‘id’ => $prefix . ‘metabox’,
‘title’ => __( ‘Repeating Field Group’, ‘cmb2’ ),
‘object_types’ => array( ‘page’, ),
) );// $group_field_id is the field id string, so in this case: $prefix . ‘demo’
$group_field_id = $cmb_group->add_field( array(
‘id’ => $prefix . ‘demo’,
‘type’ => ‘group’,
‘description’ => __( ‘Generates reusable form entries’, ‘cmb2’ ),
‘options’ => array(
‘group_title’ => __( ‘Entry {#}’, ‘cmb2’ ), // {#} gets replaced by row number
‘add_button’ => __( ‘Add Another Entry’, ‘cmb2’ ),
‘remove_button’ => __( ‘Remove Entry’, ‘cmb2’ ),
‘sortable’ => true, // beta
),
) );
// Regular text field
$cmb_group->add_group_field( $group_field_id, array(
‘name’ => __( ‘Test Text’, ‘cmb2’ ),
‘desc’ => __( ‘field description (optional)’, ‘cmb2’ ),
‘id’ => $prefix . ‘text’,
‘type’ => ‘text’,
‘show_on_cb’ => ‘cmb2_hide_if_no_cats’, // function should return a bool value
// ‘sanitization_cb’ => ‘my_custom_sanitization’, // custom sanitization callback parameter
// ‘escape_cb’ => ‘my_custom_escaping’, // custom escaping callback parameter
// ‘on_front’ => false, // Optionally designate a field to wp-admin only
// ‘repeatable’ => true,
) );
}//FRONTEND METABOX
add_shortcode( ‘cmb-form’, ‘cmb2_do_frontend_form_shortcode’ );
function cmb2_do_frontend_form_shortcode( $atts = array() ) {
global $post;
if ( ! current_user_can( ‘edit_posts’ ) ) {
return _e( ‘You do not have permissions to edit this post.’, ‘lang_domain’ );
}
if ( ! isset( $atts[‘post_id’] ) ) {
$atts[‘post_id’] = $post->ID;
}
if ( empty( $atts[‘id’] ) ) {
return “Please add a ‘id’ attribute to specify the CMB2 form to display.”;
}$metabox_id = esc_attr( $atts[‘id’] );
$object_id = absint( $atts[‘post_id’] );
$form = cmb2_get_metabox_form( $metabox_id, $object_id );
return $form;
}Forum: Plugins
In reply to: [CMB2] Repeatable Groupsi think i did something wrong with my files. what i am doing is that i created a custom plugin. this has the following structure.
myplugin(folder)
– myplugin.phpshould i copy the entire cmb2 forlder in my mplugin folder and then put
if ( file_exists( dirname( __FILE__ ) . ‘/cmb2/init.php’ ) ) {
require_once dirname( __FILE__ ) . ‘/cmb2/init.php’;
} elseif ( file_exists( dirname( __FILE__ ) . ‘/CMB2/init.php’ ) ) {
require_once dirname( __FILE__ ) . ‘/CMB2/init.php’;
}
in my php file?Forum: Plugins
In reply to: [CMB2] Repeatable Groupshave a look here
https://www.sight79.net/demosite/sample-page/Forum: Plugins
In reply to: [CMB2] Repeatable Groupshello there i cant see any errors
Forum: Plugins
In reply to: [CMB2] frontend post edit by author onlymy metaboxes include too many fields. by this <?php echo get_post_meta(get_the_ID(), ‘submitted_town’, true); ?> i can get the value filed as u suggested.
i was wondering though if there is a way to display the entire metabox without being editable, just the values.
thank u
Forum: Plugins
In reply to: [CMB2] Repeatable GroupsYes i thought so. Another issue with my repeatable fields is that the remove icon (x) and the toggle icon dont work on the front end. om the backend everything is ok
thank you
Forum: Plugins
In reply to: [CMB2] frontend post edit by author onlyyeap u r right i managed to do it by
<?php echo get_post_meta(get_the_ID(), ‘submitted_town’, true); ?>thank you
Forum: Plugins
In reply to: [CMB2] frontend post edit by author onlyOn my front end submit form i am using something like this
$cmb->add_field( array(
‘name’ => __( ‘Town’, ‘wds-post-submit’ ),
‘id’ => ‘submitted_town’,
‘type’ => ‘text’,
) );
What i would like to do is to display the value of this entry. Just the value. I tried get_post_meta( $post_id, ‘submitted_town’, true ); but still cant get the value.
any quick hint?Forum: Plugins
In reply to: [CMB2] frontend post edit by author onlydone the first part
function details(){
global $post,$current_user;
get_currentuserinfo();
if ($post->post_author == $current_user->ID) {
$object_id = $postid;
$metabox_id = ‘test_metabox’;
cmb2_metabox_form( $metabox_id, $object_id );}
return false;
what i want now is to get cmb2 values outside the form, so that they wont be editable. any quick hint?Forum: Plugins
In reply to: [CMB2] frontend post edit by author onlyHi let me be more specific. As i mentioned based on this snippet (https://github.com/WebDevStudios/CMB2-Snippet-Library/blob/master/front-end/cmb2-front-end-submit.php) i created a frontend submit form for a custom
post type. furthermore i used ‘post_author’ => $user_id.In order to submit (using the above form) the user must be logged-in.
Then i am displaying this information on the frontend using a function which looks like thisfunction details(){
$postid = get_the_ID();
$object_id = $postid;
$metabox_id = ‘test_metabox’;
cmb2_metabox_form( $metabox_id, $object_id );
}
add_shortcode( ‘details’, ‘details’ );what i would like to do is to make this information be editable only by the author (frontend). if somebody else is accessing the post he should just see the cmb2 meta vales and not being able to edit them.