Forum Replies Created

Viewing 15 replies - 1 through 15 (of 30 total)
  • Thread Starter wpquestions2018

    (@wpquestions2018)

    Hi Greg,

    This can be great, when can I expect it?

    Thread Starter wpquestions2018

    (@wpquestions2018)

    Hi Greg,

    Is this line correct

    add_action( “advert_expired”, “on_advert_expired” );

    Thanks Greg, you are a genius

    Thread Starter wpquestions2018

    (@wpquestions2018)

    Hi Greg,

    Its not working and getting below error

    “Your PHP code changes were rolled back due to an error on line 620 of file wp-content/themes/delivery-lite/functions.php. Please fix and try saving again.

    Cannot redeclare on_advert_publish() (previously declared in wp-content/themes/delivery-lite/functions.php:609)”

    I am getting the error because I am using the Ad published notification and line 609 is
    “function on_advert_publish( $post_id ) {

    The line is repeated for ad published and expired notifications

    thanks its working, but when moderating you have to select the author, where does this leave the ads posted by guys who are not registered.

    This notification is being sent to the admin because when moderating i change the author otherwise it goes with admin name as the person who posted the ad

    Just tested, its not sending any email Greg

    Thanks Greg,

    Will it send an email to users who are not registered too?

    Hi Greg,

    I want the person who posts an ad to receive a notification once its published, how do i do that please.

    Thanks for the awesome job

    Thread Starter wpquestions2018

    (@wpquestions2018)

    I have pasted the code on http://www.propertieske.co.ke

    Thread Starter wpquestions2018

    (@wpquestions2018)

    Greg That never worked at all, the code did not change anything

    I want when a user is not logged in they can pay for a normal and a featured ad, so i have 2 prices for not logged in.

    If a user logs in i want them to post for free without seeing the price field

    How can i do this please

    Thread Starter wpquestions2018

    (@wpquestions2018)

    Greg That never worked as i wished.

    I want when a user is not logged in they can pay for a normal or featured ad, so i have 2 for not logged in.

    If a user logs in i want them to post for free

    How can i do this please

    Thread Starter wpquestions2018

    (@wpquestions2018)

    Thanks Greg,

    I want the price hidden for logged in user.
    The other way round

    Thread Starter wpquestions2018

    (@wpquestions2018)

    Greg or this can be done.

    Once the price is set as free instead of having the price show as free we can replace the free text with maybe “agents”

    How can i replace the text “free” when price is set at zero

    Thread Starter wpquestions2018

    (@wpquestions2018)

    Here is the problem Greg,

    Once i add this code it shows a blank page after i submit an ad, whats the problem with the code

    add_filter( “adverts_form_load”, “customize_adverts_add_sarahagordon” );
    function customize_adverts_add_sarahagordon( $form ) {
    if( $form[‘name’] != “advert” ) {
    return $form;
    }
    foreach( $form[“field”] as $key => $field ) {
    if( $field[“name”] == “_contact_information” ) {
    $form[“field”][$key][“label”] = “Submit an ad”;
    }
    }
    return $form;
    }

    add_filter(“pending_advert”, “on_pending_advert”);
    function on_pending_advert($id, $post) {
    wp_mail(get_option(“admin_email”), “New Pending Ad”, “New Pending Ad”);
    }

    Thread Starter wpquestions2018

    (@wpquestions2018)

    Greg the problem is the functions.php for wp-adverts i have added, once i remove that it works.
    Can you know the issue, am unable to figure it out.

    Below is the code

    add_filter( “adverts_form_load”, “customize_adverts_add_sarahagordon” );
    function customize_adverts_add_sarahagordon( $form ) {
    if( $form[‘name’] != “advert” ) {
    return $form;
    }
    foreach( $form[“field”] as $key => $field ) {
    if( $field[“name”] == “_contact_information” ) {
    $form[“field”][$key][“label”] = “Submit an ad”;
    }
    }
    return $form;
    }

    add_filter(“pending_advert”, “on_pending_advert”);
    function on_pending_advert($id, $post) {
    wp_mail(get_option(“admin_email”), “New Pending Ad”, “New Pending Ad”);
    }

    // The code below you can paste in your theme functions.php or create
    // new plugin and paste the code there.

    add_filter( ‘adverts_form_load’, ‘search_by_price_form_load’ );
    add_filter( ‘adverts_list_query’, ‘search_by_price_query’ );

    /**
    * Adds price min and max fields into search form in [adverts_list].
    *
    * @param array $form Search form scheme
    * @return array Customized search form scheme
    */
    function search_by_price_form_load( $form ) {

    if( $form[‘name’] != ‘search’ ) {
    return $form;
    }

    wp_enqueue_script( ‘adverts-auto-numeric’ );

    $form[‘field’][] = array(
    “name” => “price_min”,
    “type” => “adverts_field_text”,
    “class” => “adverts-filter-money”,
    “order” => 20,
    “label” => “”,
    “placeholder” => “Price min.”,
    “meta” => array(
    “search_group” => “visible”,
    “search_type” => “half”
    )
    );

    $form[‘field’][] = array(
    “name” => “price_max”,
    “type” => “adverts_field_text”,
    “class” => “adverts-filter-money”,
    “order” => 20,
    “label” => “”,
    “placeholder” => “Price max.”,
    “meta” => array(
    “search_group” => “visible”,
    “search_type” => “half”
    )
    );

    return $form;
    }

    /**
    * Adds search by price params to WP_Query
    *
    * The query is modified only if $_GET[‘price_min’] or $_GET[‘price_max’]
    * is greater than 0.
    *
    * @param array $args WP_Query args
    * @return array Modified WP_Query args
    */
    function search_by_price_query( $args ) {

    if( adverts_request( ‘price_min’ ) ) {

    $args[“meta_query”][] = array(
    ‘key’ => ‘adverts_price’,
    ‘value’ => adverts_filter_money( adverts_request( ‘price_min’ ) ),
    ‘compare’ => ‘>=’,
    ‘type’ => ‘DECIMAL(12,2)’
    );
    }

    if( adverts_request( ‘price_max’ ) ) {
    $args[“meta_query”][] = array(
    ‘key’ => ‘adverts_price’,
    ‘value’ => adverts_filter_money( adverts_request( ‘price_max’ ) ),
    ‘compare’ => ‘<=’,
    ‘type’ => ‘DECIMAL(12,2)’
    );
    }

    return $args;
    }

    add_filter( “adverts_form_load”, “customize_adverts_search” );
    function customize_adverts_search( $form ) {
    if( $form[‘name’] != “search” ) {
    return $form;
    }
    foreach( $form[“field”] as $key => $field ) {
    if( $field[“name”] == “query” ) {
    $form[“field”][$key][“attr”][“placeholder”] = __(“Looking for …”, “adverts”);
    }
    }
    return $form;
    }

    add_filter( “adverts_form_load”, “customize_adverts_add” );
    function customize_adverts_add( $form ) {
    if( $form[‘name’] != “advert” ) {
    return $form;
    }
    foreach( $form[“field”] as $key => $field ) {
    if( $field[“name”] == “advert_category” ) {
    $form[“field”][$key][“max_choices”] = 1;
    $form[“field”][$key][“validator”][] = array( “name”=> “is_required” );
    }
    }
    return $form;
    }

    add_filter( ‘adverts_form_load’, ‘search_by_category_form_load’ );
    /**
    * Adds category dropdown into search form in [adverts_list].
    *
    * @param array $form Search form scheme
    * @return array Customized search form scheme
    */
    function search_by_category_form_load( $form ) {

    if( $form[‘name’] != ‘search’ ) {
    return $form;
    }
    $form[‘field’][] = array(
    “name” => “advert_category”,
    “type” => “adverts_field_select”,
    “order” => 20,
    “label” => __(“Category”, “adverts”),
    “max_choices” => 10,
    “options” => array(),
    “options_callback” => “adverts_taxonomies”,
    “meta” => array(
    “search_group” => “visible”,
    “search_type” => “full”
    )
    );
    return $form;
    }

    add_filter( ‘adverts_list_query’, ‘search_by_category_query’ );
    /**
    * Adds tax_query param to WP_Query
    *
    * The tax_query is added only if it is in $_GET[‘advert_category’]
    *
    * @param array $args WP_Query args
    * @return array Modified WP_Query args
    */
    function search_by_category_query( $args ) {

    if( ! adverts_request( “advert_category” ) ) {
    return $args;
    }

    $args[“tax_query”] = array(
    array(
    ‘taxonomy’ => ‘advert_category’,
    ‘field’ => ‘term_id’,
    ‘terms’ => adverts_request( “advert_category” ),
    ),
    );

    return $args;
    }

    add_filter( “adverts_manage_moderate”, “__return_true” );

    // Kenya Price Symbol

    // The code below you can paste in your theme functions.php or create
    // new plugin and paste the code there.
    add_filter(“adverts_currency_list”, “add_adverts_currency”);
    /**
    * Add new currency to the list
    *
    * @var $list Array list of currencies
    * @return Array updated list of currencies
    */
    function add_adverts_currency($list) {

    $list[] = array(
    “code”=>”Ksh”, // ISO 4217 currency code, see http://en.wikipedia.org/wiki/ISO_4217
    “sign”=>”Ksh “, // currency prefix or postfix
    “label”=>”Kenya Shillings” // currency long name
    );

    return $list;
    }
    add_filter( “adverts_form_load”, “remove_account_field” );
    function remove_account_field( $form ) {
    if( $form[‘name’] != “advert” ) {
    return $form;
    }
    foreach( $form[“field”] as $key => $field ) {
    if( $field[“name”] == “_adverts_account” ) {
    unset( $form[“field”][$key] );
    }
    }
    return $form;
    }
    // refresh button
    add_action( “init”, “my_init”, 1000 );
    function my_init() {
    remove_action( “adverts_sh_manage_actions_more”, “adext_payments_action_renew” );
    add_action( “adverts_sh_manage_actions_after”, “adext_payments_action_renew” );
    }
    // other user ads
    /**
    Plugin Name: WPAdverts Snippets – Ads By Author
    Version: 1.0
    Author: Greg Winiarski
    Description: Links “Posted By” on Ad details page, to page which displays all active ads posted by this author. Note this plugin requires WPAdverts 1.0.5 in order to work.
    */
    // The code below you can paste in your theme functions.php or create
    // new plugin and paste the code there.
    add_action( “wp”, “ads_by_author_init”, 50 );
    /**
    * Registers “Ads By Author” filter and actions.
    *
    * It does two things:
    * – replaces “by John Doe” on Ad details with link to all user Ads
    * – if current page is default Ads list and GET param “posted_by” is provided
    * then this function will modify [adverts_list] shortcode to include user
    * info above Ads list.
    *
    * @since 1.0
    */
    function ads_by_author_init() {
    add_filter( “adverts_tpl_single_posted_by”, “ads_by_author_tpl_single_posted_by”, 10, 2 );
    if( is_page( adverts_config( ‘ads_list_id’ ) ) && is_numeric( adverts_request( “posted_by” ) ) ) {

    remove_shortcode( “adverts_list” );
    add_shortcode( “adverts_list”, “ads_by_author_list” );

    add_filter( “adverts_list_pagination_base”, “ads_by_author_pagination_base” );
    add_filter( “adverts_list_query”, “ads_by_author_query” );
    }
    }
    /**
    * Generates HTML for [adverts_list] shortcode
    *
    * This function replaces default [adverts_list] callback and
    * adds author header before the listings.
    *
    * @param array $atts Shorcode attributes
    * @since 1.0
    * @return string Fully formatted HTML for adverts list
    */
    function ads_by_author_list( $params ) {
    $html = “”;
    $params[“search_bar”] = “disabled”;
    $author = get_user_by( “id”, adverts_request( “posted_by” ) );
    ob_start();
    ?>
    <style type=”text/css”>
    .ads-by-author.adverts-options {
    padding: 0.5em 1em;
    }
    .ads-by-author.adverts-options .author-logo {
    float: left;
    height: 48px;
    width: 64px;
    }
    .ads-by-author.adverts-options .author-logo > img {
    border-radius: 50%;
    }
    .ads-by-author.adverts-options .author-data {
    line-height: 24px;
    }
    </style>
    <div class=”ads-by-author adverts-options”>
    <div class=”author-logo”>
    <?php echo get_avatar( $author->user_email, 48 ) ?>
    </div>
    <div class=”author-data”>
    <?php esc_html_e( $author->display_name ) ?><br/>
    <?php esc_html_e( date_i18n( get_option( “date_format” ), strtotime( $author->user_registered ) ) ) ?>
    </div>
    </div>
    <?php
    $html.= ob_get_clean();
    $html.= shortcode_adverts_list( $params );

    return $html;
    }
    /**
    * Changes pagination base.
    *
    * This function adds “posted_by” param to the default
    * pagination URL so it is possible to paginate over
    * user submitted ads.
    *
    * @see adverts_list_pagination_base filter in wpadverts/includes/shortcodes.php
    *
    * @param string $pbase Default pagination base
    * @since 1.0
    * @return string Updated pagination base
    */
    function ads_by_author_pagination_base( $pbase ) {
    $pbase = get_the_permalink();
    $glue = stripos( $pbase, ‘?’ ) ? ‘&’ : ‘?’;

    return $pbase . $glue . “posted_by=” . intval( adverts_request( “posted_by” ) ) . ‘%_%’;
    }
    /**
    * Adds “author” param to [adverts_list] WP_Query.
    *
    * This function filters Ads by “author” param (provided in $_GET[‘posted_by’]),
    * it is applied using “adverts_list_query” filter
    *
    * @see adverts_list_query filter in wpadverts/includes/shortcodes.php
    *
    * @param string $pbase Default pagination base
    * @since 1.0
    * @return string Updated pagination base
    */
    function ads_by_author_query( $args ) {
    $args[“author”] = intval( adverts_request( “posted_by” ) );
    return $args;
    }
    /**
    * Replaces user name with link to all user ads.
    *
    * If user who posted an Ad is registered WP user, then the “By John Doe” text
    * on Ad details page is replaced with link to all user Ads.
    *
    * This change is applied using adverts_tpl_single_posted_by filter.
    *
    * @see adverts_tpl_single_posted_by filter in wpadverts/templates/single.php
    *
    * @param string $pbase Default pagination base
    * @since 1.0
    * @return string Updated pagination base
    */
    function ads_by_author_tpl_single_posted_by( $name, $post_id ) {

    $post = get_post( $post_id );
    $person = get_post_meta($post_id, ‘adverts_person’, true);

    if( $post->post_author ) {
    include_once ADVERTS_PATH . “/includes/class-html.php”;

    $link = get_permalink( adverts_config( ‘ads_list_id’ ) );
    $glue = stripos( $link, ‘?’ ) ? ‘&’ : ‘?’;

    $person = new Adverts_Html( “a”, array(
    “href” => $link . $glue . “posted_by=” . $post->post_author
    ), $person);
    }

    return sprintf( __(“by %s“, “adverts”), $person );
    }

    // character limits
    add_filter( “adverts_form_load”, “limit_title_and_location_length” );
    function limit_title_and_location_length( $form ) {
    if( $form[‘name’] != “advert” ) {
    return $form;
    }
    foreach( $form[“field”] as $key => $field ) {
    if( $field[“name”] == “post_title” ) {
    $form[“field”][$key][“validator”][] = array(
    “name” => “string_length”,
    “params” => array( “min” => 10, “max” => 60 )
    );
    }
    if( $field[“name”] == “adverts_location” ) {
    $form[“field”][$key][“validator”][] = array(
    “name” => “string_length”,
    “params” => array( “min” => 5, “max” => 40 )
    );
    }
    }
    return $form;
    }

Viewing 15 replies - 1 through 15 (of 30 total)