Hi,
i am glad you are liking the plugin so far, as for your question let me illustrate this with a code example.
Let’s assume you want to add a field named “Admin Notes” to the Adverts the field will be filled from wp-admin / Classifieds panel only, in this case your adverts_form_load filter would look like this
add_filter( "adverts_form_load", "my_adverts_form_load_admin_only" );
function my_adverts_form_load_admin_only( $form ) {
if( $form["name"] != "advert" ) {
return $form;
}
if( is_admin() ) {
$form["field"][] = array(
"name" => "my_admin_notes",
"type" => "adverts_field_text",
"order" => 25,
"label" => "Admin Notes",
"is_required" => false,
"validator" => array()
);
}
return $form;
}
Basically it comes down to just wrapping the $form["field"][] ... inside if( is_admin() ) { ... }.
Thread Starter
densdj
(@densdj)
Thank you, it works.
One more question: is it possible in “All Classifieds” admin list, make search by admin notes, and by phone number too, in “Search Classifieds”. (To prevent users double adverts, and me not to forget admin notes, in time)
This is possible but will require some custom programming.
Please see the section “Displaying Custom Field in wp-admin List” here https://wpadverts.com/documentation/custom-fields/ it explains how to add columns to the “All Classifieds” and links to tutorials which dig deeper into customizing wp-admin lists.