How to Add Custom Field to a Buddypress Update - wordpress

I would like to add a simple _custom_field to buddypress activity updates so that when you post a buddypress activity update there is an additional input field where I enter text, whenever that update is displayed in the activity stream, the update template should display the _custom_field aswell

This did it, You have to modify the activity post form to add the new input field then you create a function in bp-custom.php/functions.php to post that new value to the database, this will only work after modifying the javascript that processes the form, the following link gives a clear walk through
https://buddypress.org/support/topic/adding-a-second-element-for-posting-with-an-activity/

Related

Is there a WordPress plugin or a php code to insert a table that user can manipulate the data in it

Right now I am using the ultimate member plugin to register users. But the company asked me to change the form and allow users to insert their education qualifications in a table when registering. Users need to have a button that has the ability to insert more rows (If they have more qualifications).
As far as I know, I can't use the Ultimate Member plugin for that. I searched for many table plugins but didn't find anything that can do this task. I once had done this using code. But I don't know how to apply it to this registration form. If anyone can figure out a way to embed the code to Ultimate member (to save that table data) or any plugin that can do this, please let me know soon as possible.
Updated Question
I have tried that shortcode and got confused as it ruined the page. Now I'm trying a PHP method to solve this problem.
Thank You
Well you have many options to solve this problem. What you are actually looking for is Custom Fields.
WordPress has the ability to allow post authors to assign custom fields to a post. This arbitrary extra information is known as metadata.
Now, custom fields can be created in 2 ways.
Either you write php code in a plugin/theme
Or you you install plugin which helps you build custom fields.
What you are actually looking for is to create Repeatable Field Groups. These are the field which can be replicated. As many as you want.
Some plugins which provide facility to add them in no particular order are:
Advanced Custom Fields - Repeater Field : https://www.advancedcustomfields.com/resources/repeater/
Toolset - Repetable Field Group : https://toolset.com/course-lesson/creating-and-displaying-repeatable-field-groups/
Metabox - Meta Box Group : https://metabox.io/plugins/meta-box-group/
They all will give you ability to create repeater fields.
Repeater field can be made for both users and posts or Custom Post Types(CPT). You need them for Users. I am not sure which one of them allows you to create repeater field for Users but you can check on there website.
PS : These are all paid plugins. (They may have free version of them but repeater field comes with PRO).
Once you have created a field for users you can use that field in your registration form.
UPDATED ANSWER
As the question author wants to add the field using PHP, the field can be added as so.
After looking at all the hooks available to the user by UM (Ultimate Member) plugin. I found two hook that can be used to add fields and save in the backend.
um_after_form : Some actions after register form fields.
add_action( 'um_after_form', 'my_after_form', 10, 1 );
function my_after_form( $args ) {
// add your repetable fields here.
}
um_after_save_registration_details : Action on user registration after save details. This runs after the form is submited and user is registered. Use this to save data inside the user database.
add_action( 'um_after_save_registration_details', 'my_after_save_registration_details', 10, 2 );
function my_after_save_registration_details( $user_id, $submitted ) {
// Save field here.
// You have user_id and submitted data, do your thing here.
}

Wordpress Update CustomFields Section after updating custom field with AJAX call

I have a question regarding the CustomFields section in Wordpress when adding a new post. I have a plugin that adds a meta_box to the edit/new page of a post. Inside this meta_box, I have a button that, when pressed, uses an AJAX call to update/add custom field values to the new post.
This all works fine, however the custom field section is, logically, not updated to reflect this newly added value. I want to refresh the custom field section of the edit page for this new post to update/reload to reflect the current values..
Does anyone know if and how this should be done in Wordpress?
TIA,
John

Product field in WordPress form changes when adding a new field?

I am very new to WordPress and I am trying to edit a registration form by adding more fields. When I add a new text field, the product field no longer displays the product and price and just shows the default. I didn't make the website I just need to edit this, I am using the Gravity Forms plugin.
This is the form before editing:
And after adding a new field the product field ( in green writing) reverts to default values:
I can't figure out what makes it change so if you have come across this problem before or have any advice please let me know. Thanks!
I'd bet there is some custom code at play here is that is dependent on the field ID. When you change the field, it has a new ID, and the custom code isn't being applied. I'd suggest doing a full theme/plugin conflict (start with your theme) to see where that custom code resides:
https://docs.gravityforms.com/testing-for-a-themeplugin-conflict/

Using symfony forms, how would you create a category if text input entered

Trying to create a form in symfony, where I would be linking a Category to a Post.
This is working perfectly, when using existing categories, and the dropdown.
However, I would like there to be a text field next to the dropdown, that when is not empty, creates a category and links it to the post.
I'm currently considering just adding the text field manually (in the twig), and reading the value from the request.
Is there a more elegant way to do this using forms ?
(I can't just comment post. What are your entities ? what symfony version ? show us what you have ever tried)
after submit data :
check if text field is empty
if not, check if category name exist
if not, persist and flush new category
then $yourObject->setCategory($newCategory)
persist and flush yourObject
You could create a collection. And use the allow_add property

Wordpress custom post type structure

i am building a wordpress website for a client. i need to build 1 template type of page with a list of fields that the client can fill in to populate the page. so lets say i build a template page called Person Template. On it i have an empty picture placeholder on the left and an empty Name Field below that. On the right i have an empty "persons phone number" and "Persons email" field.
what i need to create somehow is a system that the client can enter these 4 items into wp-admin somewhere and save that as a new Person. Then they can repeat and save another Person until they have created say 100 Person pages.
How do I do this? I tried building a Custom Post Type called Person CPT. I have built a Page called Person Template. I have built some "Person CPT" posts and put them on a page but i dont know how to create the Entry Fields page for my client to use.
You're correct that you'll need to use a custom post type. To add the fields you have two options:
Add the fields using add_meta_box(). You'll then need to save this data as post meta. Then in your single-person.php template you would retrieve the meta using get_post_meta(). It's a tad cumbersome, as you need to write the markup for the meta box, hook it into an action to add it to the admin page, and verify the content before it's saved. Here's an article that walks you through it
Alternatively get yourself the Advanced Custom Fields plugin: it makes adding additional fields very quick and easy. I use it all the time.

Resources