Support Forum
Support › MB Frontend Submission › How to autopublish post entered thru Frontend Submission with all the fields?
Hi,
What I want to achieve is that people can register on my website and fill out their profile - a whole buch of fields - I am using Frontend Submission for that. Subsequently, the post plus all these fields become visible for the visitors of my website without human intervention.
To show the fields in the front end, it is my understanding that I can do that using the [rwmb_meta meta_key="field_id"] shortcode.
I.e. for each field I have to specify a line with the label and this shortcode.
This is a lot of shortcodes that in one way or the other should be added to the text of the post (without human intervention).
Is there an easy way to do that?
The way I am trying now is to use the Text Blocks plugin from Hal Gatewood. That way, only 1 shortcode needs to be included in the text of the post.
This works nicely.
Question is: how to include that shortcode (e.g. [text-blocks id="showfields"]) in the text of the post?
I want to show the fields nicely, so I am using a table for this purpose, with the TablePress plugin.
Here something weird starts...
There are 2 posts with different field values. When I use the rwmb_meta shortcode directly in the textblock, the correct values are shown for each post. But when I use the same rwmb_meta shortcode in TablePress table, 1 set of values is shown for both posts.
Any suggestion how to resolve?
Any suggestion if what I want to achieve can be done in a simpler way?
Update on this issue: I am no longer using TablePress, due to the problem I mentioned.
Instead I am using Shortcodes Ultimate plugin for the design of the output, and it works great.
So, to summarize:
- I am using the shortcodes from Shortcodes Ultimate plugin for the design
- I am defining the design with the Text Blocks plugin
- The shortcode for this text block needs to be included in the text of the post (at the end of it).
Now, only the following question from above issue remain outstanding:
- How to (automatically) include the shortcode from the Text Blocks plugin (e.g. [text-blocks id=”showfields”]) in the text of the post?
Hello, the last question can be done with the_content
filter. Please see the docs and example here.
Where should I add this filter? I have added the following to single.php:
<?php add_filter( 'the_content', 'text-blocks id=”showfields”]' ) ?>, but without success.
You should add that filter to your functions.php
file, something like this:
add_filter( 'the_content', function( $content ) {
if ( is_single() ) {
$content .= do_shortcode( '[text-blocks id="showfields"]' );
}
return $content;
} );
Aha. Thanks so much for your help.
I have added it to functions.php. It results in a 503 Service Unavailable error (while trying to use an ErrorDocument to handle the request).
Any idea?
Which PHP version are you using? The snippet above requires PHP 5.3. Also, can you make a screenshot of the functions.php file after inserting?
The PHP version on the server is 5.6.30.
I have uploaded functions.php here: https://1drv.ms/f/s!AiZg1q2e9vdxhBlxbs_Mz30DdS2c
I've just tested the code and there's no error:
https://i.imgur.com/3IJnOek.png
I don't have the Text Blocks plugin, so it just show the shortcode. If you have it installed, then the content of the shortcode will be parsed and shown automatically.
You are right. If I deactivate the Text Blocks plugin, it is shown as you stated. But once I activate the plugin again, the 503 Service Unavailable error is back.
I have changed the contents of my text block to just a single line of text, but same problem.
Hence, the problem is the plugin.
Before I start asking for support from the plugin developer, just a final question.
I am using this text block plugin to display all the fields in the frontend in the order/layout that I want.
Is there another, more appropriate way of displaying the fields in frontend?
Maybe you just write some PHP code to loop through all the fields and show them. Or I see you already use Shortcodes Ultimate, which allows you to create HTML shortcode. You can use it to display fields like:
Field 1: [rwmb_meta meta_key="field-1"]<br>
Field 2: [rwmb_meta meta_key="field-2"]<br>
...
As long as it supports running rwmb_meta
shortcode, it will work.
OK, thanks for all your help. Consider this solved.
FYI: LFFprop has found a solution for this and here is his commend, in case someone needs it:
I managed to sort it all out.
I am no longer using the Reusable Text Block plugin to display all fields after the post data. Instead I have installed the After Content Widget plugin. This adds a widget area right after the post content. In there I use the Visual editor to create the layout and show all the fields.