Forum Replies Created
-
AuthorPosts
-
[email protected]
ParticipantI use custom table to save the values.
[email protected]
ParticipantNo, everything works fine. Another question:
Someone who knows:
http://xxx.es/crear-articulo/?rwmb_frontend_field_post_id=540Knowing this url and changing the post id, anyone can enter and update all the posts...
What people do to solve it?
I think one solution is make a function wiht the add_action('template_redirect',
and check that the user has permission to modify the post id.I don't know if to do this, is important this code, that I don't understand very well:
add_filter( 'rwmb_frontend_field_value_post_id', 'my_custom_population_function', 10, 2 ); function my_custom_population_function( $value, $args ) { if ( $args['id'] === 'your_meta_box_id' ) { // Only filter for a specific form. $value = 123; } return $value; }I can see the args printed in the page, but when I call the action template_redirect, or the arguments are not yet, or I do not know how to collect them.
Is there any easier solution? Or does it have to be done this way?
Thanks,
Sergio[email protected]
ParticipantHello,
Finally I create a list-page with a table in html with a list of one of my custom post type.
In each post row I put in one column the link to edit the post.I put the shortcode in 3 places:
--> 1 Place:
I create a page named crear-articulo (to create) with the shortcode:
[mb_frontend_form post_type="articulo" edit="true" id="organizacion" post_fields="title,content" label_title="Título" submit_button="Dar de alta el artículo"]--> 2 Place:
I create a page named modificar-articulo (to update) with the shortcode:
[mb_frontend_form post_type="articulo" edit="true" id="organizacion" post_fields="title,content" label_title="Título" submit_button="Dar de alta el artículo" post_id="current"]--> 3 Place:
I add a filter to add after the $content the shortcode to can update the actual post:
[mb_frontend_form post_type="articulo" edit="true" id="organizacion" post_fields="title,content" label_title="Título" submit_button="Dar de alta el artículo" post_id="current"]To edit the post, I have some options?
--> 1 Option: Put in each row the link to the same page to create de post:
`$link = home_url( '/crear-articulo/' ); $link = add_query_arg( 'rwmb_frontend_field_post_id', $post->ID, $link ); return '<a href="'.$link.'">Editar</a>';`--> 2 Option: Put in each row the link to the update post page:
`$link = home_url( '/modificar-articulo/' ); $link = add_query_arg( 'rwmb_frontend_field_post_id', $post->ID, $link ); return '<a href="'.$link.'">Editar</a>';`Questions:
- What is the best option? Am I doing well so far?
- With the option 1, I only have to create one page to create and update posts. But I have a issue with the shortcodes. In the content field of the create page, the shortcodes are not shown, they are already half solved:
Ex: It appear this the text but not the shortcode...
Título del spoiler
Contenido oculto
Título del spoiler
Contenido oculto
Título del spoiler
Contenido ocultoBut in the update page, the shortcodes are displayed well, as in the backoffice editor:
[su_accordion class=""] [su_spoiler title="Título del spoiler" open="no" style="default" icon="plus" anchor="" class=""]Contenido oculto[/su_spoiler] [su_spoiler title="Título del spoiler" open="no" style="default" icon="plus" anchor="" class=""]Contenido oculto[/su_spoiler] [su_spoiler title="Título del spoiler" open="no" style="default" icon="plus" anchor="" class=""]Contenido oculto[/su_spoiler] [/su_accordion]The same issue have in the shortcode situated in the 3 place.
Many Thanks.
[email protected]
ParticipantOk thanks!
[email protected]
ParticipantPerfect!! Many thanks!!
[email protected]
Participantok perfect, I will use option 2:
array ( 'id' => 'fecha_inicio_evento', 'type' => 'date', 'name' => 'Fecha Inicio', 'js_options' => array( 'dateFormat' => "dd/mm/yy", ), 'save_format' => 'Y-m-d', 'timestamp' => false, ),Also, in docs: https://docs.metabox.io/fields/date/
Say that:
"Saving in timestamp also allows you to query posts with a specific order by this field".
I try to put timestamp to true. I tried to change the field of database from 'fecha_inicio_evento' => 'DATE', to 'fecha_inicio_evento' => 'TIMESTAMP', and I can not make it work...I docs it says "However, you still can sort posts by meta value if you set date format to something similar to yy-mm-dd.".
With my settings, could I sort by date?
Many thanks.
[email protected]
Participantohh perfect!!! It run fantastic.
The only thing is:
this code
if ( !empty( $groups ) ) { return []; }is
if ( empty( $groups ) ) { return []; }Many thanks with the quickly response!!
Greetings.[email protected]
ParticipantI add, don't know how, but using ACF settings, with priority 0, it run well.
thanks.
[email protected]
ParticipantI undersntand...But in the same function that I use his fields of metabox settings I registered the cpt:
I take this values in Metabox:
$mb_activacion_articulo = rwmb_meta( 'modulo_articulos_activacion', array( 'object_type' => 'setting' ), 'multi_tema_privado' ); if ($mb_activacion_articulo == 1) $show_articulo = true; $mb_slug_articulo = rwmb_meta( 'modulo_articulos_slug', array( 'object_type' => 'setting' ), 'multi_tema_privado' );And I registered the cpt:
'rewrite' => array('slug' => $slug_articulo), 'show_in_menu' => $show_articulo, 'show_in_nav_menus' => $show_articulo, 'show_in_admin_bar' => $show_articulo, register_post_type( 'articulo', $args );If I put some value priority more than 20. When I save the settings, the canghes will appear not after the refresh save, I have to refresh another time.
It's ok my explain?
Thanks
-
AuthorPosts