Free Directory, Listing & Classifieds WordPress Plugin Support General HivePress Disable Add listing button or change his functionallity

Disable Add listing button or change his functionallity

  • Author
    Posts
  • hector

    Hi.
    I have added a meta_key in the wp_usermeta table that is generated during the user registration form. What I want is for this meta_key it’s to be checked before the user can add a listing. I tried to hide the required fields so that the list cannot be sent:

    add_filter( 'hivepress/v1/forms/listing_submit',
    		   function( $form ) {
    			   unset( $form['fields']['title'] );
    			   unset( $form['fields']['description'] );
    			   $form['footer'] = '<p>Error Message!!</p>' . hivepress()->helper->get_array_value( $form, 'footer' );
    		return $form;
    	}
    );

    How can I hide the add list button? How can I write a message in the message area instead of the footer?
    Thank you very much for your help

    ihordeveloper

    The easiest way would be switching the “hp_listing_enable_submission” option value depending on the current user and custom meta you added:

    add_filter(
    	'option_hp_listing_enable_submission',
    	function( $value ) {
    		if ( 'check if user is not allowed to submit listings here' ) {
    			$value = false;
    		}
    
    		return $value;
    	}
    );
    hector

    Works correctly.
    Thank you!!

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

Subscribe

Sign In

Don't have an account? Register

Forgot password?

Register

Already have an account? Sign In

Forgot password?

Reset Password

Please enter your username or email address, you will receive a link to create a new password via email.